Closed johncrosby closed 8 years ago
Hi @johncrosby. Have you used a REST Client or CURL before? If you POST a request to 127.0.0.1:1337/user
it will create a user. To retrieve a user, you would then make a GET request to 127.0.0.1:1337/user/{USER_ID}
where the user ID would be found in the response of the POST request.
I havent used REST client or CURL before. Is CURL an instruction that I would need to type into a new Terminal tab or can It be done from the browser address bar? Good book btw 👍
Yep, CURL can be run from the command line (from most operating systems, I'm not sure about windows).
A quick intro to CURL, to POST you can use the following:
curl -H "Content-Type: application/json" -X POST -d '{"username":"john", "nationality": "Irish"}' 127.0.0.1:1337/user
where:
To retrieve a user is then:
curl 127.0.0.1:1337/user/d115de8e-5cb4-4f08-8c42-9d9151cb120f
A GET request is always easier :) You could actually paste that url into your browser and it would return the user to you.
Here's an example of me creating a user and retrieving them via CURL:
If you have any more questions let me know, and thanks for the feedback on the book! Really appreciate it! :)
Thank you thats very helpful.
I seem to have it running but how do I actually Create a user and Retrieve a user?