Promise-based Wrapper for Simple HTTP Requests built on top of Bluebird and Request
request-promise-native
first you can later just replace it by request-promise
without any breaking changes.
request
README wouldnât work.
vue-resource
community.
request-promise
library only. The vue.js community has a forum for your type of question: https://forum.vuejs.org Theyâll be able to help you.
request-promise
but forgot to put a return in front of the call to request
so the cookie was getting updated, but because I wasn't waiting on the promise to resolve, I had authentication errors.
body
or request
out of await
ing a call to request
. I don't know if I was just doing something wrong or if I really can't await
request
. Would be really cool if one could do this though. It would make testing code a lot cleaner
firsturl = 'someurl.json';
secondurl = 'some_second_url.json';
request = require('request-promise');
options = {
url: firsturl,
json: false,
header: "some_username_password"
}
request(options)
.then(function(data1) {
var data_first = JSON.parse(data1); //results from the first url
options.url = secondurl;
request(options)
.then(function(data2) {
var data_second = JSON.parse(data2);
console.log(data_second);
//why it prints the results from the first url???
})
})
await rp(âŚ)
you could use await rp(âŚ).promise()
. Since rp(âŚ)
returns a mixed object that is a certain request object and a promise at the same time that may confuse the runtime. .promise()
returns just the promise and that should definitely work with await
.