Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

NodeJS router model

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

// Get to home controller req and res function
router.get('/', app.home);
//---- Inside controller.js
const home = (req, res) => {
  res.setHeader('Cache-Control', 'no-cache');
  res.status(200).json({
    status: 'Ok'
  });
};
//----


// NOT FOUND Middleware
router.use((req, res) => {
  res.status(404).json('not found');
});

module.exports = router;
Comment

PREVIOUS NEXT
Code Example
Javascript :: countdown recursion javascript 
Javascript :: change text based on dropdown selection javascript 
Javascript :: what is closure in javascript 
Javascript :: how to append element in array angular 
Javascript :: convert int to string javascript 
Javascript :: google scripts urlfetchapp hearders and body 
Javascript :: dropdowndirection 
Javascript :: node_modules/metro/src/lib/attachWebsocketServer.js 
Javascript :: Fill rect in jspdf 
Javascript :: sumar un mes a una fecha javascript moment 
Javascript :: how to navigate to another page with settimeout reactjs 
Javascript :: nextjs link image 
Javascript :: interpolation in js 
Javascript :: mongoose autoincrement 
Javascript :: how to convert string to toggle case in javascript 
Javascript :: leave page 
Javascript :: js intellisence not working 
Javascript :: spread operator react 
Javascript :: shorthand if in javascript with return 
Javascript :: datatable sAjaxSource get output 
Javascript :: recursive function scheme 
Javascript :: dropzone react npm 
Javascript :: input in html table 
Javascript :: node js middleware for parsing formdata 
Javascript :: test cases in react 
Javascript :: fs readfile encoding 
Javascript :: jquery selector input name regex 
Javascript :: how to remove only green background from video using ffmeg nodejs 
Javascript :: how to change css using javascript 
Javascript :: deploy react to azure : web.config 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =