我有一个Rest方法用于接收用户数据,下面是CURL命令:
curl -X POST -H "Content-Type: application/json" -d "data_test" http://localhost:8080/datum
现在我正在尝试使用JavaScript进行POST数据:
var request = new XMLHttpRequest();
let url='http://localhost:8080/datum';
let data=body;
request.open('POST', url, true);
request.setRequestHeader("Content-Type", "application/json");
request.send(data);
但是这没有接收到任何东西。 我正在一个Chrome扩展中使用这个javascript。