From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext
Unlock this course with a free trial
Join today to access over 25,000 courses taught by industry experts.
Create and test a POST endpoint - JavaScript Tutorial
From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext
Create and test a POST endpoint
- Okay, so at this point we have several endpoints on our server, all of which allow us to get some sort of data from the server. However, one thing we still haven't looked at is how to actually modify data on the server. Now, while we've used get for all of our other endpoints, in order to allow the client to actually make the kind of modifications we want them to be able to make, we're going to use app.post, which allows the client to make post requests to a certain end point. And for those of you who don't know, the main difference between a post request and a get request is that with a post request, you're allowed to send extra data along with the request. The client is able to send extra data along with that request that is. So what we're going to do is define a post endpoint and what this endpoint is going to allow the client to do is send a new person object that we want to add to the fake database and it'll add that and then send a response back. So for our endpoint, we're…
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Learning objectives1m 34s
-
(Locked)
Learn the basics of writing a Node server3m 52s
-
(Locked)
Create and set up a Node.js project3m 59s
-
(Locked)
Create and run a basic Express server5m 47s
-
(Locked)
Create and test a GET endpoint6m 27s
-
(Locked)
Read a file with the fs package4m 40s
-
(Locked)
Create and test a POST endpoint8m
-
(Locked)
-
-
-