博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
express json_使用Express发送JSON响应
阅读量:2503 次
发布时间:2019-05-11

本文共 693 字,大约阅读时间需要 2 分钟。

express json

When you listen for connections on a route in Express, the callback function will be invoked on every network call with a Request object instance and a Response object instance.

当您在Express中侦听路由上的连接时,将在每个带有请求对象实例和响应对象实例的网络调用中调用回调函数。

Example:

例:

app.get('/', (req, res) => res.send('Hello World!'))

Here we used the Response.send() method, which accepts any string.

在这里,我们使用了Response.send()方法,该方法可以接受任何字符串。

You can send to the client by using Response.json(), a useful method.

您可以使用Response.json() (一种有用的方法Response.json()将发送到客户端。

It accepts an object or array, and converts it to JSON before sending it:

它接受一个对象或数组,并在发送之前将其转换为JSON:

res.json({ username: 'Flavio' })

翻译自:

express json

转载地址:http://koqgb.baihongyu.com/

你可能感兴趣的文章
python主进程或者主线程是否会等待子线程或子进程的问题
查看>>
安装visio和office16
查看>>
GridView分页排序
查看>>
后端系统开发之白名单机制
查看>>
java基础学习——7、String类和StringBuffer类的区别
查看>>
js基础
查看>>
sklearn 中 make_blobs模块
查看>>
C#之桶中取黑白球问题
查看>>
python学习笔记之多个装饰器
查看>>
自己创建一个android studio在线依赖compile
查看>>
【android】安卓开发apk列表
查看>>
清北学堂Day3
查看>>
JavaScript高级特性-实现继承的七种方式
查看>>
20121016学习笔记四
查看>>
EntityFramework 学习 一 Stored Procedure
查看>>
Sliverlight之 故事板
查看>>
Java 必知必会的 20 种常用类库和 API
查看>>
HDU 1087 Super Jumping! Jumping! Jumping!
查看>>
0007_初始模块和字节码
查看>>
[效率提升]如何管理好你的电脑文件
查看>>