Resource | GET (Read) | POST (Create) | PUT (update) | DELETE (Delete) |
---|---|---|---|---|
/books | ดึงข้อมูลหนังสือทั่งหมด | สร้างหนังสือใหม่ | อัพเดตข้อมูลหนังสือทั่งหมด | ลบหนังสือทั่งหมด |
books/2 /books/{:id} | ดึงข้อมูลหนังสือตามไอดี | ไม่อนุญาตให้เข้าถึง (HTTP 405) | อัพเดตหนังสือตามไอดี | ลบหนังสือตามไอดี |
/books/authors | ดึงข้อมูลผู้แต่งหนังสือทั่งหมด | สร้างข้อมูลผู้แต่งหนังสือ | อัพเดทข้อมูลผู้แต่งหนังสือทั่งหมด | ลบผู้แต่งหนังสือทั่งหมด |
Last active
September 16, 2018 04:18
-
-
Save NSLog0/c7e5e32bc2bf009c2c2acc6e4b9c1266 to your computer and use it in GitHub Desktop.
http-rest-tut-article
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
url: "http://localhost/api/books/2", | |
type: "POST", | |
data: JSON.stringify(data), | |
headers: { | |
"Content-Type": "application/json", | |
"X-HTTP-Method-Override": "PUT" }, | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.use(function (req, res, next) { | |
res.contentType('application/json'); | |
next(); | |
}); | |
app.use(app.router); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment