我正在尝试使用React Native构建的应用程序正常运行。根据屏幕截图,我得到了错误。有人可以帮我弄清楚它的含义以及如何解决? enter image description here
请参见下面与此错误相关的代码
tatic async func(route, params, verb) {
// console.warn(JSON.stringify(params));
let { orderStore } = Store;
const url = `${host}/${route}`
let options = Object.assign({ method: verb }, params ? { body: JSON.stringify(params) } : null);
options.headers = Api.headers()
const data = await LocalDb.getUserProfile();
if (params != null && params.type === 'social') {
const username = params.email;
const password = '1234';
const hash = new Buffer(`${username}:${password}`).toString('base64');
options.headers['Authorization'] = `Basic ${hash}`;
}
else
if (data != null) {
const username = data.email;
const password = data.password;
const hash = new Buffer(`${username}:${password}`).toString('base64');
options.headers['Authorization'] = `Basic ${hash}`;
}
return fetch(url, options).then(resp => {
// console.log('Api response is ------------->>>>>>', resp);
let json = resp.json();
if (resp.ok) {
return json
}
return json.then(err => { throw err });
}).catch(json => {
console.log('error is ', json)
// console.log('Api response is ------------->>>>>>', json);
Api.showAlert();
return;
});
}
tatic showAlert() {
// Works on both iOS and Android
Alert.alert(
'Network Error!',
'Click Ok To Restart App.',
[
{ text: 'OK', onPress: () => RNRestart.Restart() },
],
{ cancelable: false },
);
}