I want to send form data values to my webview url before it loaded. I'm getting this values from redux.
This is what I tried. But It's not working
let token=this.props.usersData ? this.props.usersData.token : null
let currencyValue=this.props.usersData ? this.props.usersData.currencyValue :null
let paymentValue=this.props.usersData ? this.props.usersData.paymentValue : null
let formdata = new FormData();
formdata.append("token", token)
formdata.append("currencyValue", currencyValue)
formdata.append("paymentValue", paymentValue)
return (
<WebView
style={styles.webView}
scrollEnabled={true}
source=
{{uri: 'https://myweb.com/tokenization?type=datasave&test=yes',
headers: { 'Content-Type': 'application/x-www-form-urlencoded', body:formdata }}}
/>
);
Please note that props values are getting without any issue (no null values there)
You must use injectedJavaScript
and pass a string, try this:
return (
<WebView
style={styles.webView}
scrollEnabled={true}
source={{ uri: 'https://myweb.com/tokenization?type=datasave&test=yes' }}
injectedJavaScript={`window.token=${token}; window.currencyValue={currencyValue}; window.paymentValue=${paymentValue}`}
/>
);
then in your myweb.com you can get this variables with window.token
, window.currencyValue
, window.paymentValue
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.