I'm attempting to make a POST request using node and the request module and I can't get it to work (I'm getting a 301 response). I'm trying to post to a URL that takes the following parameters accessToken, wager, chance, and direction.
here's my code:
var request = require('request');
function repeater() {
request.post(
'https://betterbets.io/api/betDice',
{ form: { accessToken: 'myToken', wager: 0.000000002, chance: 49.5, direction: 0 } },
function(err, response, body) {
if (err) {
console.log(err);
}
console.log(response);
repeater();
});
}
repeater();
I'm not sure what to do. I've had no problems using the request library for GET requests but I can't figure it out with POST requests for the life of me.
您缺少标题
headers: {'content-type' : 'application/x-www-form-urlencoded'}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.