From 57d58d47a83d40830e30679f0cbde67664f1f8d9 Mon Sep 17 00:00:00 2001 From: Kevin Midboe Date: Mon, 1 Jul 2019 19:24:46 +0200 Subject: [PATCH] Content type for elasticsearch set to json and changed from axios to fetch --- src/api.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/api.js b/src/api.js index 948a32f..467f27e 100644 --- a/src/api.js +++ b/src/api.js @@ -215,6 +215,9 @@ const getEmoji = () => { */ const elasticSearchMoviesAndShows = (query) => { const url = new URL(path.join(ELASTIC_INDEX, '/_search'), ELASTIC_URL) + const headers = { + 'Content-Type': 'application/json' + } const body = { "sort" : [ @@ -238,7 +241,12 @@ const elasticSearchMoviesAndShows = (query) => { "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 }) }