fetch.js php,fetch,react.js_多个fetch异步调用,不能拿到调用之后的值,fetch,react.js - phpStudy...

多个fetch异步调用,不能拿到调用之后的值

export const editCase = () => (dispatch, getState) => {

let caseObject = jquery.extend(true, {}, getState().caseDetail.caseObject)

let platforms = getPlatforms()

let countries = getCountries()

dispatch(initializeCreator(caseObject, platforms, countries, true))

}

执行dispatch函数的时候,此时platforms,countries还没有拿到值

const initializeCreator = (caseObject, platforms, countries, isEdit) => ({

type: types.EDIT_CASE,

caseObject,

platforms,

countries,

isEdit

})

const getPlatforms = () => {

fetch(constants.FETCH_URL + '/platforms', {

mode: 'cors',

method: 'GET',

cache: 'default',

credentials: 'include'

})

.then(response => response.json())

.then(platforms => {

return platforms

})

}

const getCountries = () => {

fetch(constants.FETCH_URL + '/region/countryList', {

mode: 'cors',

method: 'GET',

cache: 'default',

credentials: 'include'

})

.then(response => response.json())

.then(countryNames => {

let countryOptions = []

countryNames.map((countryName, index) => {

countryOptions.push({countryName})

})

return {

countryNames,

countryOptions

}

})

}

相关阅读:

c const 关键字疑问

linux系统下udp包没有收到

请教下 string::data 或 string::c_str的应用方向?

面试经典问题:Cookie禁用了,Session还能用吗?

SUI与swiper能否兼容?

win10 hyper-v 安装Ubuntu黑屏

WSS、SSL 和 https 之间的关系

实在是找不出问题在哪了,麻烦大家找找BUG出在哪

传统diff算法的算法复杂度为什么是o(n3)?

支付宝新版本app支付接口的notify_url在哪里添加?

ubuntu16.04装好后1920*1080显示不全是怎么回事啊?

JDBC访问数据库, set names utf8 无法解决乱码问题.

jq 如何获取多列的高度

c++ 类名后<>里面的内容代表什么?

BitmapDescriptor 得到的百度地图 Marker 显示模糊

SQL添加记录的数据来源于同一个表

Session没有更新

redis java 保存对象,为什么多用序列号,而不直接用redis提供的hash

python wifi模块使用 出现错误。

php 为什么常量可以用数组定义 静态变量却不能

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值