Add timeout to JSON request

Can someone please show me how to add a timeout to an JSON request? So for example, how can I add a timeout to this simple request:

app.request.json('https://my-url.com', function (data) {
  console.log(data);
})

Also, if I do add a timeout then should the request also include a success and error component?

Thanks :grinning:

use app.request(…)

Please could you show me a simple example that uses success, error and timeout?

Examples are in the documentation

i made an example here.
jsfiddle
its that what you need?

1 Like