简体   繁体   中英

How could I send response using json instead of jade?

//This is my index.js file

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;

//This is my index.jade file

extends layout

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

Finally, I want to do the same thing using json.

Just use res.send(/*your json*/); . Like:

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

See the docs .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM