Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 188.8.131.52 release ready!
In React-native we don’t need to import any third-party library to make API network calls like Retrofit or Volly. In React-native we use fetch() method to perform network calls operations.
In the fetch() method we have two parameters.
1- API URL:- In my case “https://mywebsite.com/endpoint/” this URL is gonna be my API URL.
2- JSON Object:- After the API URL we have a JSON object which contains several keys like method, headers, and body.
NOTE–> Please make sure that the key’s name must be the same as it is written in the code. Because it is predefined keys.
method:- At Method key, you need to define that which kind of API you are executing as GET API, POST API or any other.
headers:- At headers key, you need to define your headers like in my case I am passing three headers Accept, Content-type, and CustomHeaders.
body:- At body key, you need to send the params in that key. Like I am hitting a POST request so it can contain params also so in that key put the JSON data that you want to Post.
After that, you need to call another method to get the response.
then():- We use then() method an call back. When we close the fetch() method brackets then we call then() method to get the response.
Now we got the response in responseJson.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.