In the last episode we’ve created custom collection types by using Strapi’s admin panel. We’ve also added some sample data into the newly created collection types and we’ve started to use the REST API which is automatically provided for collection types.
So far we’ve used only unauthenticated access to retrieve data from Strapi by using HTTP GET requests in the browser. Therefore we’ve added corresponding collection types permissions to the Public role.
In this episode we’ll continue using the automatically generated REST API Strapi is providing for our custom collection types. This time we’ll not limit it to only retrieve data by using an HTTP GET request. We’ll also create new data by using an HTTP POST request. However, creating new data should not be possible for unauthenticated users. So we need to:
Add the corresponding permissions for the creation of data to the Authenticated role only
Create a new user which is assigned to the Authenticated role
Perform authentication by using JWT
Perform the HTTP POST request in an authenticated way
Using just the browser to send HTTP GET request to the Strapi API in the last episode is an approach which is very limiting when we want to have full control over our requests. Therefore we’ll switch to a tool which is called Postman. With Postman we’re able to take full control of our HTTP requests and responses.
This is a CodingTheSmartWay.com tutorial.
---------------------
Musik:
Night Owl by Broke For Free is licensed under a Creative Commons Attribution License.
(http://freemusicarchive.org/music/Bro...)
#strapi #javascript #backend #nodejs
Watch video Getting Started With Strapi - Episode 3: Authentication online without registration, duration hours minute second in high quality. This video was added by user CodingTheSmartWay 31 May 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 20,935 once and liked it 210 people.