【发布时间】:2019-06-10 08:27:37
【问题描述】:
我对使用 API 和这里还是很陌生。
我正面临 CORS 问题。
错误如下。
Access to XMLHttpRequest at 'https://api-us.faceplusplus.com/facepp/v3/detect?api_key={0}&api_secret={1}&image_url={2}&return_attributes={3}'
from origin 'http://localhost:3111' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource
;
这是我的代码
async submit(){
let imgSrc = document.getElementById("photo").src
const self = this
try{
let headers = {headers:{"Access-Control-Allow-Origin":"*",}}
console.log(headers)
let response = await self.$axios.$post(CONSTANTS.API_URL,self.createParam(imgSrc),headers)
console.log(response)
}catch(error){
console.log(error)
}
},
我可以在 Google Chrome 上的 Restlet Client 上检查此 API 是否正常工作。
this is screen shot on Restlet Client
帮帮我。
【问题讨论】:
标签: google-chrome vue.js cors