Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
REST API
和
JSON
|
167
使用一个单独的表,类似于一个审核队列,单独地记录这些删除请求,引用涉及的度假产
品。不过,这个表会更适合管理员使用。
假设你在第
5
章正确地设置了
Jest
,那么现在应该能够运行测试了
(
npm test
),而且这些
API
测试将被选中执行
(
Jest
会查找任何以
.test.js
结尾的文件)。你会看到有
3
个测试通过
了,
1
个没通过,即未完成的
DELETE
/api/vacation/:sku
。
15.7
 小结
读完本章,希望你会问:“就这些了吗?”在这个时候,你很可能已经认识到了,
Express
的主要作用就是响应
HTTP
请求
。至于这些请求是做什么的以及如何来响应完全由你决
定。不管你需要响应
HTML
、
CSS
、普通文本
,还是
JSON
,使用
Express
都能轻而易举实
现。你甚至可以响应二进制文件类型。例如,动态构造和返回图片并不会多难。从这个意
义上来说,
API
不过是
Express
支持的多种响应方式中的一种。
下一章将通过构建一个单页应用把这些
API
都使用起来
。而且,会换一种方式重新实现前
面章节所完成的页面功能。
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099