React Native - W / unknown:InspectorPackagerConnection:无法连接到打包程序,将以静默方式重试

时间:2017-11-30 07:45:21

标签: javascript react-native react-native-android

我试图在Android上运行我的React Native,从rest API获取数据时一切看起来都不错,

但我不知道为什么当我想将数据发送到rest API时,控制台日志会告诉我

  

W/unknown:InspectorPackagerConnection: Couldn't connect to packager, will silently retry

这是我尝试过的代码:

try {
  console.log(Constants.APILink + `DoAudit/PostCompleteAuditSchedulev1`, header + `token`)
  axios.post(Constants.APILink + `DoAudit/PostCompleteAuditSchedulev1`, header, {
    headers: {
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Authorization": "Bearer " + Queries.getPersistentData('token')
    }
  })
// NEVER RUN TO THIS STATEMENT OR SHOWING ME AN ERROR IN LOGCAT
    .then(res => {
      if (res.data == 0) {
        console.log("Upload success HEADER");

        var path = '/storage/emulated/0/Documents' + '/testx.txt';
        RNFS.writeFile(path, JSON.stringify(mediaListFinding + auditid), 'ascii')
          .then((success) => {
            console.log('FILE WRITTEN!');
            let dataAdd = NativeModules.SqliteModule;
            dataAdd.insert(mediaListFinding, 0, auditid, function (value){
              console.log("Service callback insert " + value);
            })
          })
          .catch((err) => {
            console.log(err.message);
            });
        this.setState({
          loaderStatus: false
        })
      }
    })
    .catch((error) => {
      console.log(error)
      this.setState({
        loaderStatus: false
      })
    });
} catch (error) {
  console.log(error)
  this.setState({
    loaderStatus: false
  })
}

我试图抓住每个错误并使用控制台告诉我发生了什么,但logcat只是告诉我这个:

logcat

下一个日志永远不会寻求

  

Upload Success HEADER或错误捕获

0 个答案:

没有答案