From 063b805a44c02105fa130d724d96b55aab65e164 Mon Sep 17 00:00:00 2001
From: Henrik Askjer <henrik.askjer@uib.no>
Date: Fri, 24 Sep 2021 15:56:23 +0200
Subject: [PATCH] Use api_pref and make api-key for old api a local argument in
 axios.get

---
 src/components/DictionaryView.vue | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue
index 003322c..d51dbc6 100644
--- a/src/components/DictionaryView.vue
+++ b/src/components/DictionaryView.vue
@@ -99,6 +99,7 @@ function compare_by_hgno(lemma_text) {
   }
 }
 
+/*
 axios.interceptors.request.use(function (config) {
     if (!config.url) {
       config.headers["x-api-key"] = "ZkYiyRVXxH86ijsvhx3cH4SY5Iik2ijI3BKVJGMm"
@@ -107,7 +108,7 @@ axios.interceptors.request.use(function (config) {
     return config;
   }, function (error) {
     return Promise.reject(error);
-  });
+  });*/
 
 function navigate_to_article(self, source) {
   let config = {headers: {}}
@@ -137,7 +138,7 @@ function navigate_to_article(self, source) {
 }
 
 function navigate_to_search(self, query) {
-  axios.get(self.api_old + 'search?q=' + query)
+  axios.get(self.api_pref + 'search?q=' + query, { headers: {"x-api-key":"ZkYiyRVXxH86ijsvhx3cH4SY5Iik2ijI3BKVJGMm"}}) // API-key to be removed or reimplemented with a ci-variable with the new API
   .then(function(response){
     self.search_results = response.data
     if (! self.search_results.length) {
@@ -162,7 +163,7 @@ function navigate_to_search(self, query) {
 }
 
 function navigate_to_word(self, word) {
-  axios.get(self.api_old + 'suggest?q=' + word)
+  axios.get(self.api_pref + 'suggest?q=' + word, { headers: {"x-api-key":"ZkYiyRVXxH86ijsvhx3cH4SY5Iik2ijI3BKVJGMm"}})  // API-key to be removed or reimplemented with a ci-variable with the new API
   .then(function(response){
     self.search_results = response.data.filter(result => result.match == word).sort(compare_by_hgno(word))
     if (! self.search_results.length) {
@@ -205,9 +206,6 @@ export default {
       return (this.waiting_for_articles || this.waiting_for_metadata) && this.$route.name != 'root'
     },
     api_pref: function() {
-      return oda_dev + '/' + this.lang + '/article/'
-    },
-    api_old: function() {
       return api_endpoint + '/' + this.lang + '/article/'
     },
     get_oda_api: function() {
-- 
GitLab