Use Text Plain in Express.js Rest API

This project will demonstrate how to Use Text Plain in Express.js Rest API

  • LearnExpressJSRestAPIWithRealApps
    • api
      • demo.api.js
      • index.js
    • server.js
var DemoAPI = {
    helloWorld: function (request, response) {
        response.setHeader('Content-Type', 'text/plain');
        response.send('Hello World');
    }
};

module.exports = DemoAPI;
var express = require('express');
var router = express.Router();

var DemoAPI = require('./demo.api');

router.get('/demo/helloworld', DemoAPI.helloWorld);

module.exports = router;
var express = require('express');
var app = express();

app.use('/api', require('./api/index'));

app.listen(9090, function () {
    var host = server.address().address;
    var port = server.address().port;
    console.log("Server listening at http://%s:%s", host, port)
});

Screenshots