0 votes
1 view
in Web Technology by (15.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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...