简体   繁体   English

react-native error RCTJSONStringify()遇到以下错误:JSON写入中的无效类型(NSURL)

[英]react-native error RCTJSONStringify() encountered the following error: Invalid type in JSON write (NSURL)

I am trying to use react-native-fbsdk in my react-native app. 我试图在我的react-native应用程序中使用react-native-fbsdk It was working fine untill yesterday. 它一直很好,直到昨天。 But, today it gives a weird error stating RCTJSONStringify() encountered the following error: Invalid type in JSON write (NSURL). 但是,今天它给出了一个奇怪的错误,说明RCTJSONStringify()遇到以下错误:JSON写入(NSURL)中的类型无效。

RN v0.42.0 RN v0.42.0

Here is my code: 这是我的代码:

  _fbAuth(error, result) {
    if (error) {
      console.log("error");
      alert("login has error: " + result.error);
    } else if (result.isCancelled) {
      console.log("login cancelled");
      alert("login is cancelled.");
    } else {
      AccessToken.getCurrentAccessToken().then((data) => {
        console.log("login success");
        console.log(data.accessToken.toString());
        let accessToken = data.accessToken;
        alert(data.accessToken.toString());
        const responseInfoCallback = (error, result) => {
          if (error) {
            console.log(error);
          } else {
            console.log(result);
          }
        }

        const infoRequest = new GraphRequest(
          '/me',
          {
            accessToken: accessToken,
            parameters: {
              fields: {
                string: 'email,name,first_name,middle_name,last_name'
              }
            }
          },
          responseInfoCallback
        );

        // Start the graph request.
        new GraphRequestManager().addRequest(infoRequest).start();
      });
    }
  }

  render() {
    console.log("in new render");
    return (
      <View style={styles.container}>
      <LoginButton
        publishPermissions={["publish_actions"]}
        onLoginFinished={this._fbAuth}
        onLogoutFinished={() => alert("logout.")}/>
      </View>
    );
  }

The error information printed in debugger: 调试器中打印的错误信息:

错误信息

I get the above error while calling the graphAPI in the function responseInfoCallback . 我在函数responseInfoCallback中调用graphAPI时遇到上述错误。 Any ideas what is happening ? 有什么想法发生了什么?

Update 1: 更新1:

This error happens only when remote debugger is turned on!! 仅当远程调试器打开时才会发生此错误! Else it is not happening. 否则它不会发生。 But without remote debugger, I cannot proceed with developing the app. 但是没有远程调试器,我无法继续开发应用程序。 Are there any other methods to see log statements of react-native app other than remote debugger ? 除了远程调试器之外,还有其他方法可以查看react-native app的日志语句吗?

Update 2: 更新2:

The RCTJSONStringify() error happens only behind proxy. RCTJSONStringify()错误仅发生在代理后面。 And also https fetch calls does not work under proxy. 并且https fetch调用在代理下也不起作用。 I tested in an open network, it works fine. 我在一个开放的网络中测试过,它运行正常。 I guess, it is to add some proxy information to RN app. 我想,它是向RN app添加一些代理信息。 I think it is related to APP transport security 我认为它与APP传输安全性有关

If you turn the debugger off, you can see the proper error in the XCode console. 如果关闭调试器,可以在XCode控制台中看到正确的错误。 Access it from Xcode menu View/Debug Area/Activate console, if it's not enabled automatically. 从Xcode菜单访问它View / Debug Area / Activate console,如果它没有自动启用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM