In the previous recipe, we covered how to get data from an API using fetch. In this recipe, we will learn how to POST data to the same API. This app will emulate creating a forum post, and the request for the post will have title, body, and user parameters.
Sending data to a remote API
Getting ready
Before going through this recipe, we need to create a new empty app named remote-api-post.
In this recipe, we will also be using the very popular axios package for handling our API requests. You can install it via the Terminal with yarn:
yarn add axios
Alternatively, you can use npm:
npm install axios --save