Hi,
I am using webview for get method.there is lot of pass data method.but how can i display data from api webview to native.
accesstoken is only on native.if i create api and disply record in webview how can i pass accesstoken to webview.
WEBVIEW:
function MobileOceanPage() {
const [filteredDataSource, setFilteredDataSource] = useState([]);
useEffect(async()=> {
axios
.get(url, {
headers: {
Authorization: `bearer ${accesstoken}`,//how can i pass accesstoken from native here
},
})
.then(({ data }) => {
setFilteredDataSource(data);
});
},[]
)
return(
with token
margin : '0 auto'}} id='profile' type="text">
{filteredDataSource.map(item=>
{item.profile_name}
{item.upload_title}
)}
);
}
NATIVE CODE:
function MyWallet(props) {
const webviewRef = React.useRef(null);
async function onMessage(data) {
let accesstoken = JSON.parse(await AsyncStorage.getItem("token")).token;//here only accesstoken pass
return Alert.alert( '', accesstoken, );
}
return (
<>
source={{uri:url }} startInLoadingState={true} ref={webviewRef} onMessage={onMessage} /> > ); } The issue is how can i pass this native accesstoken to webview
Replies
Know the answer? Post it — somebody with the same question will find it here.