问题
I tried to send post request but always get: 403
and Authentication requires
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
const http = new XMLHttpRequest();
const url = "https://mywebsite.com/api/comment";
const params = 'comment=test';
http.open("POST", url, false, login, password);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send(params)
If I try to log in I get: {"status":"nok","message":"Not JSON"}
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
const http = new XMLHttpRequest();
const url = "https://mywebsite.com/api/login";
const params = 'login=admin&password=admin'
http.open("POST", url, false);
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.send(params);
I wolud like to change some data by request before I log in manually.
来源:https://stackoverflow.com/questions/49597999/post-request-with-xmlhttprequest-javascript