Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass post parameters in react native WebView?

I have a url I want to open in my app using WebView to avoid the user having to be redirected out of the app to the mobile browser. However the the web page I want to show requires some post parameters like from a post form. If it was a GET situation I woul'd have simply appended the parameters to the url.

<WebView
    source={{uri: 'https://mypage.com/index.php', headers: '---', body: '---'}}
    style={{marginTop: 20}}
  />

Do I put them in headers or in body, and in what format? Or is there another way? I would like to have the parameters in a key value format i.e cat=himalayan&dog=pug&fish=shark

like image 620
Wellington Avatar asked Feb 05 '18 20:02

Wellington


1 Answers

Put this piece of code in the body:

{ source: { uri: 'https://mypage.com/index.php', method: 'POST', body: 
'cat=himalayan&dog=pug&fish=shark' } 
like image 166
Paula Marín Avatar answered Oct 21 '22 12:10

Paula Marín