Created
November 6, 2018 17:25
-
-
Save Musinux/944d45950747e80ebf334fa924546f5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Axios = require('axios') | |
exports.startToEndProcessQuery = function (req, res) { | |
return Axios.get('/explore.articlesearch.v1/favouriteSearch?edismax=true&storeId=00016&language=fr-FR&country=FR&query=' + req.params.str + '&rows=1000&page=1&profile=orSearch&null&__t=1541347156148') | |
.then(function (response) { | |
let stringIds = '' | |
let limits = response.data.regularResults.resultIds.length > 50 ? 50 : response.data.regularResults.resultIds.length | |
for (let i = 0; i < limits; i++) { | |
stringIds += response.data.regularResults.resultIds[i] + '&ids=' | |
} | |
stringIds = stringIds.substring(0, stringIds.length - 5) | |
return Axios.get('/evaluate.article.v1/betty-variants?storeIds=00016&ids=' + stringIds + '&country=FR&locale=fr-FR&null&__t=1541350054684') | |
}) | |
.then(function (response) { | |
res.json(response.data.result) | |
}) | |
.catch(function (error) { | |
console.log(error) | |
res.status(500).send('Error occured') | |
}) | |
} | |
exports.startToEndProcessQuery = async function (req, res) { | |
try { | |
const {data: {regularResults: {resultIds}}} = await Axios.get('/explore.articlesearch.v1/favouriteSearch?edismax=true&storeId=00016&language=fr-FR&country=FR&query=' + req.params.str + '&rows=1000&page=1&profile=orSearch&null&__t=1541347156148') | |
let stringIds = '' | |
let limits = resultIds.length > 50 ? 50 : resultIds.length | |
for (let i = 0; i < limits; i++) { | |
stringIds += resultIds[i] + '&ids=' | |
} | |
stringIds = stringIds.substring(0, stringIds.length - 5) | |
const {data: {result}} = await Axios.get('/evaluate.article.v1/betty-variants?storeIds=00016&ids=' + stringIds + '&country=FR&locale=fr-FR&null&__t=1541350054684') | |
res.json(result) | |
} catch (error) { | |
console.log(error) | |
res.status(500).send('Error occured') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment