Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

router NodeJS

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 :: Material-ui add box icon 
Javascript :: convert number to hex js 
Javascript :: console.table in javascript 
Javascript :: scroll js 
Javascript :: console.log printing object object 
Javascript :: nodejs class template export 
Javascript :: how to find the radius of a loacation in node js 
Javascript :: vb net textbox regular expression 
Javascript :: react router dom default params 
Javascript :: jquery append text for 5 seconds 
Javascript :: angularjs How to get Capacitor Storage values before doing http call IONIC 6 
Javascript :: map js 
Javascript :: remove btn 
Javascript :: mongoose auto increment 
Javascript :: post request enabled in express js 
Javascript :: Get the language of a user 
Javascript :: convert div to pdf javascript 
Javascript :: js check if array contains value 
Javascript :: bootstrap 4 form validator with jquery 
Javascript :: javascript link to google maps route 
Javascript :: jquery default value 
Javascript :: bcrypt create encrypted password 
Javascript :: js backwards loop 
Javascript :: environment texture in three.js 
Javascript :: how to draw vertical dash line in react native 
Javascript :: js array entries 
Javascript :: javascript add to undefined 
Javascript :: send message to user facebook game 
Javascript :: run javascript in flutter 
Javascript :: change the origin of html canvas 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =