13

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

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:

Error message

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

Update 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 ?

Update 2:

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

Lakshman Diwaakar
  • 7,207
  • 6
  • 47
  • 81

1 Answers1

1

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.

  • it works!! But this is tiresome. each time you click the run button and it takes some minutes to finish the app. I am guessing the error is due to proxy issues, coz i cant make any network calls too. – Lakshman Diwaakar Mar 07 '17 at 10:23
  • And on top of that, I use redux-logger, which looks cryptic in xcode console. Kinda frustrating to work in Xcode console rather than RN debugger. – Lakshman Diwaakar Mar 07 '17 at 10:33