Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.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 反应型本机类型错误:未定义不是对象(正在评估';response.success';)_Javascript_Android_Wordpress_React Native - Fatal编程技术网

Javascript 反应型本机类型错误:未定义不是对象(正在评估';response.success';)

Javascript 反应型本机类型错误:未定义不是对象(正在评估';response.success';),javascript,android,wordpress,react-native,Javascript,Android,Wordpress,React Native,我正在尝试使用React Native构建一个应用程序。我根据屏幕截图得到错误。有人能帮我弄清楚它是什么意思以及如何修复它吗? 请参阅下面与此错误相关的代码 tatic async func(route, params, verb) { // console.warn(JSON.stringify(params)); let { orderStore } = Store; const url = `${host}/${route}` let options = Object.assign(

我正在尝试使用React Native构建一个应用程序。我根据屏幕截图得到错误。有人能帮我弄清楚它是什么意思以及如何修复它吗?

请参阅下面与此错误相关的代码

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 },
);