Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

express get

const express = require('express');
const app = express();

app.get('/', (req, res)=> {
  res.send('Hello World');
}) 

app.get('/api', (req, res)=> { // http://localhost:80/api?question=hello
  let data = decodeURI(req.query.question);
  if(!data) return res.json({error: "data is not found"});
  res.json({you_sayed: data}); // { you_sayed: "hello" }
}) 

app.listen(3000,()=>{
 console.log("starting...");
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: tinymce get plain text 
Javascript :: json data types 
Javascript :: scroll bar disappears after closing modal 
Javascript :: nestjs custom error class validator 
Javascript :: datatable highlight cells based on their content 
Javascript :: importing svg into cra 
Javascript :: handling event in jsx 
Javascript :: how to add svg file in react 
Javascript :: javascript closure function example 
Javascript :: search box in material angular 
Javascript :: string charat javascript 
Javascript :: javascript remove required attribute 
Javascript :: import and export type in js 
Javascript :: react native Setting a timer for a long period of time 
Javascript :: Upload a file using ExpressJS+Multer 
Javascript :: multiple queries in node js 
Javascript :: mongoose create 
Javascript :: how to remove last element from array in javascript 
Javascript :: kendo grid toolbar custom button click event jquery 
Javascript :: function prototype in javascript 
Javascript :: function declaration and function definition in javascript 
Javascript :: remove storybook from project 
Javascript :: remove index from array javascript 
Javascript :: linear equations calculator 
Javascript :: iframe url redirect 
Javascript :: javascript how to open a file 
Javascript :: js format date 
Javascript :: jquery add 
Javascript :: delete duplicate array javascript 
Javascript :: what does = mean in javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =