无法使用axios(Get)Vue.js从服务器检索用户信息

时间:2018-08-06 11:28:56

标签: javascript vue.js vuejs2

我想检索用户信息(例如电子邮件,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!中打印

0 个答案:

没有答案