Akila

Akila

  • NA
  • 216
  • 34.5k

how to pass bearer token from webview to react native

Jan 31 2022 5:08 AM

Hi,

I am host react js web view form. and i am using that link in react native app.form design was fine but i cant pass bearer token from webview to native.i am using @react-native-async-storage/async-storage package for both webview and native.

native:

import { WebView } from 'react-native-webview';

 <WebView source={{ uri: url}}  />

 asyncstorange get method in native:

let accesstoken = JSON.parse(await AsyncStorage.getItem("token")).token;

webview:

 let userData =  AsyncStorage.getItem('token');

  userData.then((a) => {

    const accessToken=JSON.parse(a);

        fetch(`url`, {

          method: "POST",

          headers:{Accept:'application/json','Content-type':'application/json', Authorization: "Bearer " + accessToken},

          body: JSON.stringify({ Email, Password }),

        })

        toast.success(""success)        

    })

}


Answers (1)