我正在尝试使用axios向此API发出POST请求: https://laravel.com/docs/5.8/validation#custom-validation-rules
我收到调用API的状态200,但显示“未指定参数API Key
或TEXT
或将其设置为null。”
我可以正确调用POST请求吗?我正在遵循在axios的其他示例和文档中看到的内容
我也尝试过"Content-Type":"application/json"
,但这会返回错误:
已被CORS政策阻止:对预检请求的响应未通过访问控制检查:
它没有HTTP正常状态。
api() {
var text = this.text;
var api_key = "XXXXXXXXX";
var lang_code = "en";
axios({
method: "POST",
url: "https://apis.paralleldots.com/v5/emotion",
data: {
text: text,
api_key: api_key,
lang_code: lang_code
},
headers: {
"Content-Type": "text/plain;charset=utf-8"
}
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
}