ary*_*yan 12 javascript fetch reactjs redux fetch-api
我有这个调用函数的动作:
dispatch(Api({url: "my_url", method: "POST", data: data}))
Run Code Online (Sandbox Code Playgroud)
这里我将数组作为数据传递..
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)
});
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我用fetch用mode:'no-cors',我想我想过去的所有arguements ..在这里,我的身体是我作为传递简单arguement阵列..
当我看到响应时,它就像:
body: null
bodyUsed: false
headers: Headers
ok: false
status: 0
statusText: ""
type: "opaque"
url:""
Run Code Online (Sandbox Code Playgroud)
在这里我的身体没被使用..
这里有什么问题?需要帮忙
| 归档时间: |
|
| 查看次数: |
14809 次 |
| 最近记录: |