post request with XMLHttpRequest javascript

本小妞迷上赌 提交于 2020-01-16 18:09:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!