Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native post request like a form submit

I am trying to achieve a similar thing in React Native any idea how can i do this

<form action="http://example.com/some-url-end-point" method="POST">
  <input type="hidden" name="q" value="a">
</form>

Is there a possibility to do something similar in React Native. I can do this in a web application. But in react native window.document doesn't exist. So I can't submit a form dynamically or in any way.

Basically what happens is I send some data to a 3rd party payment gateway with POST method data. Any idea how I can achieve this in React Native?

Edit: I need a solution that changes when submitted a web view opens up which changes the location of the browser, and sends data to that location in post method format

A similar question I found regarding this for Javascript implementation was this JavaScript post request like a form submit I need to achieve something similar in react native.

like image 561
Adeel Imran Avatar asked Jan 05 '18 10:01

Adeel Imran


People also ask

How do I send a post request in react native?

To trigger a Post request from the UI side in react -native, we can send the Request option as a second Parameter. Project Structure: The project should look like this: Example: Here, we are sending request options as a second parameter along with the body. This body is handled in API.


1 Answers

Since what you are trying to do is actually create a web form and redirect after that, why not create your form using HTML? You can do it using WebView. It's source prop accepts HTML directly or a remote source, and by doing so you can get the result you wish.

like image 169
H. Tugkan Kibar Avatar answered Oct 17 '22 07:10

H. Tugkan Kibar