Last active
May 1, 2022 08:00
-
-
Save Yudhajitadhikary/5217566656be13077b8a5bc62312191a to your computer and use it in GitHub Desktop.
This file contains 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 algoliasearch= require("algoliasearch") | |
module.exports={ | |
getAlgoliaResults: function (request_object={},name){ | |
const SearchIndex=name=='name'?'Demo-Index-desc(name)':name=='price'?'Demo-Index-desc(price)':'Demo-Index' | |
return new Promise((resolve,reject)=>{ | |
algoliasearch(<APPLICATION ID>,<ADMIN API KEY>).initIndex(SearchIndex).search('',request_object).then(response=>{ | |
resolve(response) | |
}) | |
.catch(error=>reject(error)) | |
}) | |
}, | |
getAlgoliaSearchResults: function (request_object={},query){ | |
const SearchIndex='Demo-Index' | |
return new Promise((resolve,reject)=>{ | |
algoliasearch(<APPLICATION ID>,<ADMIN API KEY>).initIndex(SearchIndex).search(query,request_object).then(response=>{ | |
resolve(response) | |
}) | |
.catch(error=>reject(error)) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment