-
Run app.js
-
Go to http://localhost:3000/
-
Execute this command on your JavaScript console, for example on your Google Chrome: a. Post
- Use form "Add a new product" or execute this command on your console :
jQuery.post("/api/products", { "title": "Your Product Title", "description": "Your Product Description", "style": "Your Product style" }, function (data, textStatus, jqXHR) { console.log("Post resposne:"); console.dir(data); console.log(textStatus); console.dir(jqXHR); });
b. Read all products
jQuery.get("/api/products/", function (data, textStatus, jqXHR) { console.log("Get resposne:"); console.dir(data); console.log(textStatus); console.dir(jqXHR); });
c. Read single product depend on the _id for example 50fe4c6f9433c4bb05000002
jQuery.get("/api/products/50fe4c6f9433c4bb05000002", function(data, textStatus, jqXHR) { console.log("Get resposne:"); console.dir(data); console.log(textStatus); console.dir(jqXHR); });
d. Update single product depend on the _id for example 50fe4c6f9433c4bb05000002
jQuery.ajax({ url: "/https/github.com/api/products/50fe4c6f9433c4bb05000002", type: "PUT", data: { "title": "Your New Product Title", "description": "Your New Description", "style": "Your New Product Style" }, success: function (data, textStatus, jqXHR) { console.log("Post resposne:"); console.dir(data); console.log(textStatus); console.dir(jqXHR); } });
e. Delete single product depend on the _id for example 50fe4c6f9433c4bb05000002
jQuery.ajax({ url: "/https/github.com/api/products/50fe4c6f9433c4bb05000002", type: "DELETE", success: function (data, textStatus, jqXHR) { console.log("Post resposne:"); console.dir(data); console.log(textStatus); console.dir(jqXHR); } });
-
Notifications
You must be signed in to change notification settings - Fork 0
sandi-ga/RESTful
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
Create RESTful API using Node.js, Express & Mongoose
Resources
Stars
Watchers
Forks
Releases
No releases published