Skip to content

Instantly share code, notes, and snippets.

Created October 8, 2018 16:41
What would you like to do?
Node.js chained HTTP requests using promises through the request-promise-native module
const rp = require("request-promise-native");
.then(function(response) {
// Start second request, e.g., based on results of first request
console.log("Response length: ", response.length);
if (response.length > 100) {
return rp("");
.then(function(response2) {
// Process response of 2nd request
console.log("Data: ", response2.substring(0,10));
.catch(function(error) {
console.log("Error: ", error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment