react.js - react+redux 调服务端接口中,报Fetch API cannot load 怎么解决

查看:417
本文介绍了react.js - react+redux 调服务端接口中,报Fetch API cannot load 怎么解决的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

method: 'GET',
        headers: {
            'Accept': 'application/json',
          form-urlencoded
            'Content-Type': 'application/json;charset=utf-8'
        },
        mode : 'cors'  //实现跨域
        // headers: form.getHeaders()

我们使用了mode : 'cors' //实现跨域的方法,但是还是不能跨域,后台的token取不到,所有接口中的信息都调不到,全部报错信息为:

Fetch API cannot load http://devapi.jiaj1.com.cn:8080/masterdatas/geo/provinces. Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:8080' is therefore not allowed access.
undefined:1 Uncaught (in promise) TypeError: Failed to fetch(…)

抱大腿了,请问该怎么解决?

引用文字

解决方案

你用浏览器开发工具抓一下请求,应该已经请求成功,但是可能服务器没有返回合适的Access-Control-Allow-Origin头。

这篇关于react.js - react+redux 调服务端接口中,报Fetch API cannot load 怎么解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆