My node app is supposed to POST to an external server, so I'm playing with request
from NPM. I want to verify it's working, but I'm not entirely sure I'm doing that right.
I've tried both of these methods
request({
url: url,
method: 'POST',
form: { a: 1}
}
request({
url: url,
method: 'POST',
json: true,
body: { a: 1}
}
In my test when I hit my own server, req.body
shows the right object when I do json
true. However that just means I'm passing a JSON header. The API I actually need to hit is expecting a normal POST, not JSON.
So when I try to verify that request
is working right when I use form
, my server says req.body
is an empty object.
EDIT
I am posting to external API fine using form
, but on my own server, express is leaving request.body
as empty object.