gpt4 book ai didi

javascript - 我如何使用 json 而不是 jade 发送响应?

转载 作者:太空宇宙 更新时间:2023-11-03 22:32:36 26 4
gpt4 key购买 nike

//这是我的index.js文件

var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Movie Database' });
});

module.exports = router;

//这是我的index.jade文件

extends layout

block content
h1= title
p Welcome to #{title}

最后,我想使用 json 做同样的事情。

最佳答案

只需使用res.send(/*你的json*/);。喜欢:

res.send({ title: '...' });

请参阅docs .

关于javascript - 我如何使用 json 而不是 jade 发送响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34370578/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com