react-native error RCTJSONStringify()遇到以下错误:JSON写入中的无效类型(NSURL) [英] react-native error RCTJSONStringify() encountered the following error: Invalid type in JSON write (NSURL)

查看:273
本文介绍了react-native error RCTJSONStringify()遇到以下错误:JSON写入中的无效类型(NSURL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的react-native应用中使用 react-native-fbsdk 。它一直很好,直到昨天。但是,今天它给出了一个奇怪的错误,指出 RCTJSONStringify()遇到以下错误:JSON写入(NSURL)中的类型无效。

I am trying to use react-native-fbsdk in my react-native app. 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).

RN v0.42.0

这是我的代码:

  _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:

在函数 responseInfoCallback 中调用graphAPI时出现上述错误。有什么想法吗?

I get the above error while calling the graphAPI in the function responseInfoCallback. Any ideas what is happening ?

更新1:

此错误仅发生当远程调试器打开时!!否则它不会发生。但是没有远程调试器,我无法继续开发应用程序。除了远程调试器之外,还有其他方法可以查看react-native app的日志语句吗?

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 ?

更新2:

RCTJSONStringify()错误仅在代理后面发生。并且https提取调用在代理下也不起作用。我在一个开放的网络中测试过,它运行正常。我想,它是向RN app添加一些代理信息。我认为这与 APP运输安全有关

The RCTJSONStringify() error happens only behind proxy. And also https fetch calls does not work under proxy. I tested in an open network, it works fine. I guess, it is to add some proxy information to RN app. I think it is related to APP transport security

推荐答案

如果关闭调试器,可以在XCode控制台中看到正确的错误。从Xcode菜单访问它View / Debug Area / Activate console,如果它没有自动启用。

If you turn the debugger off, you can see the proper error in the XCode console. Access it from Xcode menu View/Debug Area/Activate console, if it's not enabled automatically.

这篇关于react-native error RCTJSONStringify()遇到以下错误:JSON写入中的无效类型(NSURL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆