requestify
requestify copied to clipboard
Sending body and headers in a request
Hey,
So I ran into this problem earlier: if you use a function other than .request(), you are not able to successfully send a request that contains headers and a body.
E.g. the below will not send a successful request
requestify.post(URL, {
body: {data: AA},
headers: {token: BBBB}
})
In order to send a successful request with both body and headers (and likely other attributes you may want), you need to send:
requestify.request(URL, {
method: 'POST',
body: {data: AA},
headers: {token: BBBB}
})
Posting this here in case there is already a solution on the way or someone else runs into the same issue.
Hello, you can use the example below:
requestify.post('http://your_url', { id: 1, name: 'Test', message: 'This is my payload!!' }, {
headers: {
token: BBBB
}
});