Monday, 11 February 2019

Node.js localhost loads and loads but doesn't work

I am trying to call a search engine from this node API but for some reason node doesn't work. I tried the client.search call without the API and it works. Thank you for any input!const express = require('express'); const bodyParser = require('body-parser'); const PORT = 4000; var client = require ('./connection.js'); var argv = require('yargs').argv; var getJSON = require('get-json'); let app = express(); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ exptended: true })); app.get("/search", function results(request, response) { client.search({ index: 'club', type: 'clubinfo', body: { query: { match: { "name": "Italian club" } }, } },function (error, response,status) { if (error){ console.log("search error: "+error) } else { console.log("--- Response ---"); console.log(response); console.log("--- Hits ---"); response.hits.hits.forEach(function(hit){ console.log(hit); }) } }); }); app.listen(PORT, () => console.log('wowzers in me trousers, Listening on port ' + PORT)); ​

Submitted February 11, 2019 at 10:05PM by CharlieCannedFruit

No comments:

Post a Comment