Creating a Band – For Real, This Time
Learn to create a band through a JSON POST request in our application.
We'll cover the following
The tried-and-true way of creating a new record against a REST back-end is to send a POST request. JSON:API has the following to say about how to do that:
A resource can be created by sending a POST request to a URL that represents a collection of resources. The request MUST include a single resource object as primary data. The resource object MUST contain at least a type member.
Since we already established that the URL that represents the collection of bands is
/bands, we can deduce we need to send a POST request there. Let’s not waste any more time:
The code to be removed is commented and newly added code is highlighted.