【发布时间】:2016-05-12 05:13:41
【问题描述】:
我有这个调用函数的动作:
dispatch(Api({url: "my_url", method: "POST", data: data}))
这里我将数组作为数据传递..
import fetch from 'isomorphic-fetch'
export default function Api({url, method, headers, data}={}){
return dispatch => {
console.log(data)
console.log(url)
console.log(method)
console.log(JSON.stringify(data))
let response = fetch(url, {
mode: 'no-cors',
method: method || null,
body: data || null,
}).then(function(response) {
console.log("response");
console.log(response)
});
}
}
在这里我使用fetch 和mode:'no-cors' 我想我正在传递所有的争论。我的身体是一个简单的数组,我作为争论传递..
当我看到回复时,就像:
body: null
bodyUsed: false
headers: Headers
ok: false
status: 0
statusText: ""
type: "opaque"
url:""
这里我的身体没有被使用..
这里有什么问题?需要帮助
【问题讨论】:
-
你有答案吗?我也面临类似的问题...
-
是的,问题出在服务器端..您应该允许所有来源获取
-
是的,这对我有帮助。我在 web 配置文件中添加了
'。但是我已经改为 axios 而不是 'isomorphic-fetch'
标签: javascript reactjs fetch redux fetch-api