I am building a search engine that queries the Twitter and Wiki APIs server-side after the client POSTs the search string. When I was still completely client-side the AJAX request to the Wiki API looked like:
$.ajax({
url: 'https://en.wikipedia.org/w/api.php',
data: {
action: 'query',
list: 'search',
srsearch: searchString, // variable pulled from input
format: 'json',
//origin: 'https://www.mediawiki.org'
},
xhrFields: {
withCredentials: true
},
dataType: 'jsonp' // will probably use 'json' now that I'm server-side
}).done( function ( data ) {
searchParser(data);
});
... //searchParser() below
Now, I have implemented a Node.js web app that takes the search string from a client-side form POST on the home page (index.ejs). The server will then render the results page (results.ejs) with the wiki and twitter search results. Twitter API search is already handled with BoyCook's TwitterJSClient.
I would like to know the best way to perform this exact query from my server. I have been looking around and cannot find a succinct answer. Does anyone have any advice on this?