Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node.js return json

server.get('/', (req, res) => {
  const user = { name: 'Hero', isLearning: true, level: 'apprentice' };
  return res.json(user);
})
Comment

node js return json

var http = require('http');

var app = http.createServer(function(req,res){
    res.setHeader('Content-Type', 'application/json');
    res.end(JSON.stringify({ a: 1 }));
});
app.listen(3000);

// > {"a":1}
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript lowercase string except first letter of every word 
Javascript :: get value of span jquery 
Javascript :: react app.js 
Javascript :: set value to element paragraph in javascript 
Javascript :: how to play music in js 
Javascript :: : not foundram Files/nodejs/npm: 3: 
Javascript :: faker.js lorem 
Javascript :: placeholder in angular 9 select with working required 
Javascript :: open google chrome in puppeteer macos 
Javascript :: javascript remove all child elements 
Javascript :: javascript local storage delete 
Javascript :: div onchange react 
Javascript :: jquery change href value 
Javascript :: nuxt small scroll 
Javascript :: express server template 
Javascript :: js remove all objects from array where value 
Javascript :: react proptypes reuse shape 
Javascript :: js add css class to element 
Javascript :: template literal syntax not working 
Javascript :: JS not executing 
Javascript :: nuxt window is not defined 
Javascript :: javsacript split string at position 
Javascript :: javascript format number with commas 
Javascript :: format number javascript with comma 
Javascript :: redirect to url in javascript 
Javascript :: js get distinct values from array 
Javascript :: browserrouter react 
Javascript :: nested destructuring javascript 
Javascript :: node js express mongodb find all documents 
Javascript :: reload page 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =