Content type for elasticsearch set to json and changed from axios to fetch

This commit is contained in:
2019-07-01 19:24:46 +02:00
parent e06850ebe6
commit 57d58d47a8

View File

@@ -215,6 +215,9 @@ const getEmoji = () => {
*/ */
const elasticSearchMoviesAndShows = (query) => { const elasticSearchMoviesAndShows = (query) => {
const url = new URL(path.join(ELASTIC_INDEX, '/_search'), ELASTIC_URL) const url = new URL(path.join(ELASTIC_INDEX, '/_search'), ELASTIC_URL)
const headers = {
'Content-Type': 'application/json'
}
const body = { const body = {
"sort" : [ "sort" : [
@@ -238,7 +241,12 @@ const elasticSearchMoviesAndShows = (query) => {
"size": 6 "size": 6
} }
return axios.post(url, body) return fetch(url.href, {
method: 'POST',
headers: headers,
body: JSON.stringify(body)
})
.then(resp => resp.json())
.catch(error => { console.log(`api error searching elasticsearch: ${query}`); throw error }) .catch(error => { console.log(`api error searching elasticsearch: ${query}`); throw error })
} }