Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript React native:未处理的承诺拒绝:TypeError:undefined不是对象_Javascript_React Native_Expo - Fatal编程技术网

Javascript React native:未处理的承诺拒绝:TypeError:undefined不是对象

Javascript React native:未处理的承诺拒绝:TypeError:undefined不是对象,javascript,react-native,expo,Javascript,React Native,Expo,不幸的是,我对代码有一个经典的“现在只有上帝知道”的时刻(或者因为它是由我的团队成员编写的)。 我返回到一个项目,已经搁置了相当长的一段时间,现在在返回,并试图更新一些软件包等。我得到一些恼人的错误 现在,当我尝试运行我的React原生项目时,最主要的问题是: * http://blurred-IP/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:150165:3

不幸的是,我对代码有一个经典的“现在只有上帝知道”的时刻(或者因为它是由我的团队成员编写的)。 我返回到一个项目,已经搁置了相当长的一段时间,现在在返回,并试图更新一些软件包等。我得到一些恼人的错误

现在,当我尝试运行我的React原生项目时,最主要的问题是:

* http://blurred-IP/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:150165:37 in _callee$
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:271:30 in invoke
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:28 in invoke
- node_modules/regenerator-runtime/runtime.js:170:17 in Promise$argument_0
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
- node_modules/regenerator-runtime/runtime.js:169:27 in Promise$argument_0
- node_modules/regenerator-runtime/runtime.js:192:38 in enqueue
- node_modules/regenerator-runtime/runtime.js:216:8 in exports.async
* src/screens/main/DashBoard.js:150:18 in splitServices
* http:blurred-IP/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:150661:69 in fetchEverything$
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:271:30 in invoke
- node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
- node_modules/regenerator-runtime/runtime.js:135:28 in invoke
- node_modules/regenerator-runtime/runtime.js:145:19 in Promise.resolve.then$argument_0
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:194:17 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:458:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:407:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:142:17 in __guard$argument_0
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue
据我所知,问题应该出现在DashBoard.js文件的第150行。 该行及其周围的代码:

async fetchEverything(){
const services=await NetworkingService.fetchActiveServices()
const events=await NetworkingService.fetchAllEvents()
const things=wait NetworkingService.fetchAllThings()
const splitservices=等待此消息。splitservices(服务)
等待此消息。setstatesync({
eventData:events.events,
requestData:splitservices.requests,
offerData:splitservices.offers,
thingData:things.data.things,
})
this.createRenders()
}
splitServices=async(服务)=>{
const list=services.services
常量请求=[]
const offers=[]
for(设i=0;i
列表可能是空的?空着


任何帮助都将不胜感激

将变量值从undefined更改为{}(空对象)应该可以工作,如果这个问题不久前解决了的话

编辑:
或者[]

我猜当您尝试访问
服务时,
服务
未定义。服务
。我想您需要检查
NetworkingService.fetchActiveServices()
是否返回有效响应。可能在这里,请尝试const list=services.services??[]并在调用函数之前声明函数