Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (19.9k points)

what command I should write in ExpressJS file just so that exposes a single HTTP endpoint (/api/search?symbol=$symbol&period=$period)

Working

    app.get('/api/search/', (req, res) => {

     res.send(req.query)

 })

Not working:

    app.get('/api/search?symbol=$symbol&period=$period', (req, res) => {

    res.send(req.query)

})

1 Answer

0 votes
by (25.1k points)

app.get('/api/search?symbol=$symbol&period=$period', (req, res) => {

    res.send(req.query)

})

In place of this, you have to write below code

const note = require('../app/controllers/note.controller.js');

  // Create a new API CALL

    app.get('/comment/get', note.index); // In socket.controller.js i have function with the name of index 

//note.controller.js file code

exports.index = (req, res) => {

    var requestTime = moment().unix();

    req.body = req.query;

console.log(req.body); // you will able to get all parameter of GET request in it.

}

Let me know if i need to explain more about

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...