Skip to content
Snippets Groups Projects
Commit 063b805a authored by Henrik Askjer's avatar Henrik Askjer
Browse files

Use api_pref and make api-key for old api a local argument in axios.get

parent 4e43d1ab
No related branches found
No related tags found
No related merge requests found
...@@ -99,6 +99,7 @@ function compare_by_hgno(lemma_text) { ...@@ -99,6 +99,7 @@ function compare_by_hgno(lemma_text) {
} }
} }
/*
axios.interceptors.request.use(function (config) { axios.interceptors.request.use(function (config) {
if (!config.url) { if (!config.url) {
config.headers["x-api-key"] = "ZkYiyRVXxH86ijsvhx3cH4SY5Iik2ijI3BKVJGMm" config.headers["x-api-key"] = "ZkYiyRVXxH86ijsvhx3cH4SY5Iik2ijI3BKVJGMm"
...@@ -107,7 +108,7 @@ axios.interceptors.request.use(function (config) { ...@@ -107,7 +108,7 @@ axios.interceptors.request.use(function (config) {
return config; return config;
}, function (error) { }, function (error) {
return Promise.reject(error); return Promise.reject(error);
}); });*/
function navigate_to_article(self, source) { function navigate_to_article(self, source) {
let config = {headers: {}} let config = {headers: {}}
...@@ -137,7 +138,7 @@ function navigate_to_article(self, source) { ...@@ -137,7 +138,7 @@ function navigate_to_article(self, source) {
} }
function navigate_to_search(self, query) { 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){ .then(function(response){
self.search_results = response.data self.search_results = response.data
if (! self.search_results.length) { if (! self.search_results.length) {
...@@ -162,7 +163,7 @@ function navigate_to_search(self, query) { ...@@ -162,7 +163,7 @@ function navigate_to_search(self, query) {
} }
function navigate_to_word(self, word) { 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){ .then(function(response){
self.search_results = response.data.filter(result => result.match == word).sort(compare_by_hgno(word)) self.search_results = response.data.filter(result => result.match == word).sort(compare_by_hgno(word))
if (! self.search_results.length) { if (! self.search_results.length) {
...@@ -205,9 +206,6 @@ export default { ...@@ -205,9 +206,6 @@ export default {
return (this.waiting_for_articles || this.waiting_for_metadata) && this.$route.name != 'root' return (this.waiting_for_articles || this.waiting_for_metadata) && this.$route.name != 'root'
}, },
api_pref: function() { api_pref: function() {
return oda_dev + '/' + this.lang + '/article/'
},
api_old: function() {
return api_endpoint + '/' + this.lang + '/article/' return api_endpoint + '/' + this.lang + '/article/'
}, },
get_oda_api: function() { get_oda_api: function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment