我想检索用户信息(例如电子邮件,DoB等),并且在组件中我这样做:
const instance = axios.create({
timeout: 1000,
headers: {
"content-type": "application/json",
"APPLICATION_ID": "XXXXX",
"CLIENT_KEY": "XXXXX",
"token": "Token"
}
});
instance.get("url/" + app.id)
.then(function(response) {
console.log("I am here!");
app.phone = response.data.result._User.phone;
app.email = response.data.result._User.email;
app.dob = response.data.result._User.dob;
app.website = response.data.result._User.website;
app.country = response.data.result._User.ountry;
})
.catch(function(error) {
console.log("Error!");
});
但它总是提供以下错误消息:
Failed to load https:url/XXXXXX: Request header field token is not allowed by Access-Control-Allow-Headers in preflight response.
如何解决此问题?
此外,在控制台Error!
中打印