使用XMLHttpRequest javascript发布请求

时间:2018-04-01 12:21:08

标签: javascript xmlhttprequest http-headers protractor

我尝试发送帖子请求但始终获得:403Authentication 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)

如果我尝试登录,我会收到:{"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);

我想在手动登录之前按要求更改一些数据。

0 个答案:

没有答案