Each call to Requestify allows you to pass through an Options object, the definition of that object is described here: Requestify API Reference
You are using the short method for POST, so I'll show that first, but this same syntax will work for put as well, notice that get, delete, head do not accept a data argument, you send url query parameters through the params config property.
requestify.post(url, data, config)
requestify.put(url, data, config)
requestify.get(url, config)
requestify.delete(url, config)
requestify.head(url, config)
Now, config has a timeout property
timeout {number}
Set a timeout (in milliseconds) for the request.
So we can specify the a timeout of 60 seconds with this syntax:
var config = {};
config.timeout = 60000;
requestify.post(url, data, config)
or inline:
requestify.post(url, data, { timeout: 60000 })
So lets put that together now into your original request:
as @Jabalaja pointed out, you should catch any exception messages, however you should do this with the error argument on the continuation.
(.then)
requestify.post('https://example.com/', {
email: 'foo@bar.com'
}, {
timeout: 60000
})
.then(function(response) {
var answer = response.getBody();
console.log("answer:" + answer);
}, function(error) {
var errorMessage = "Post Failed";
if(error.code && error.body)
errorMessage += " - " + error.code + ": " + error.body
console.log(errorMessage);
// dump the full object to see if you can formulate a better error message.
console.log(error);
});