my code is almost ready, but my friend has said it is running as a GET instead of as a POST. I don't see GET anywhere in this code, so how would I change it into a POST?
const request = require("request");
const username = "myUserName";
const password = "myPassword";
const options = {
url: "https://siteToPostTo.com/api/v1/statuses",
auth: {
user: username,
password: password
},
body: JSON.stringify({
status: 'automated message to post'
})
};
request(options, function(err, res, body) {
if (err) {
console.dir(err);
return;
}
console.dir("headers", res.headers);
console.dir("status code", res.statusCode);
console.dir(body);
});
the cmd error message is "'headers' 'status code' '<"error":"Not implemented">'
EDIT: I tried adding method: "POST" in 3 different positions in the syntax but am still getting the same error
EDIT: almost working now, the error i am getting is " 'headers' 'status code' '<"errors":<"detail":"Internal Server Error">>' "
EDIT: okay, it seems like it is almost there, here is the last error "status code 400 <"errors":<"detail":"Internal server error">>
EDIT: in the body section, i was told to delete JSON.stringify and replace it with something else, but I can't figure out what