From 6b64844c93f237c2bb3ddc5364ce22a684b457b7 Mon Sep 17 00:00:00 2001 From: Alexander Vokin Date: Tue, 5 Nov 2024 15:32:28 +0800 Subject: [PATCH 1/2] update axios and put away axiosAdapter as unnecessary --- package.json | 3 +-- src/scripts/StoreRestApi.js | 16 +++++----------- src/scripts/StoreTalismanApi.js | 3 --- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 818105a..5aaa097 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,8 @@ } }, "dependencies": { - "@vespaiach/axios-fetch-adapter": "^0.3.1", "@babel/runtime": "^7.10.5", - "axios": "^0.26.1", + "axios": "1.7.7", "bootstrap": "3.4.1", "d3": "^3.3.8", "icanhaz": "0.10.3", diff --git a/src/scripts/StoreRestApi.js b/src/scripts/StoreRestApi.js index c7fd014..6f7559f 100644 --- a/src/scripts/StoreRestApi.js +++ b/src/scripts/StoreRestApi.js @@ -2,14 +2,12 @@ import axios from 'axios'; import Sitemap from './Sitemap'; import StorePouchDB from './StorePouchDB'; import urlJoin from 'url-join'; -import fetchAdapter from '@vespaiach/axios-fetch-adapter'; export default class StoreRestApi { constructor(config, baseUrl, sitemapsPath = 'sitemaps/') { this.localDataStore = new StorePouchDB(config); this.axiosInstance = axios.create({ baseURL: baseUrl, - adapter: fetchAdapter, }); this.axiosInstance.defaults.headers.post['Content-Type'] = 'application/json'; this.axiosInstance.defaults.headers.put['Content-Type'] = 'application/json'; @@ -19,15 +17,11 @@ export default class StoreRestApi { setAxiosInterceptors() { this.axiosInstance.interceptors.response.use(response => { - //TODO return it when change axios to fetch - // const [contentType] = response.headers['content-type'].split(';'); - // if (contentType !== 'application/json') { - // const error = new Error(`Incorrect response type`); - // return Promise.reject(error); - // } - // if (response.headers['content-type']) { - // console.log(response.headers['content-type']); - // } + const [contentType] = response.headers['content-type'].split(';'); + if (contentType !== 'application/json') { + const error = new Error(`Incorrect response type`); + return Promise.reject(error); + } return response; }); } diff --git a/src/scripts/StoreTalismanApi.js b/src/scripts/StoreTalismanApi.js index 8f25d21..ceb057f 100644 --- a/src/scripts/StoreTalismanApi.js +++ b/src/scripts/StoreTalismanApi.js @@ -1,5 +1,4 @@ import axios from 'axios'; -import fetchAdapter from '@vespaiach/axios-fetch-adapter'; import StoreRestApi from './StoreRestApi'; import urlJoin from 'url-join'; import * as browser from 'webextension-polyfill'; @@ -36,7 +35,6 @@ export default class StoreTalismanApi extends StoreRestApi { const response = await axios({ method: 'get', url: urlJoin(this.axiosInstance.defaults.baseURL, 'meta.json'), - adapter: fetchAdapter, }); return response.data.APP_NAME; } @@ -102,7 +100,6 @@ export default class StoreTalismanApi extends StoreRestApi { const response = await axios({ method: 'get', url: `${tUrl}/oauth/token`, - adapter: fetchAdapter, }); try { if (response.data.preferred_username) { From b700d414cd676feb836a3016dd7260c4e01234d8 Mon Sep 17 00:00:00 2001 From: Alexander Vokin Date: Tue, 5 Nov 2024 15:36:08 +0800 Subject: [PATCH 2/2] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5aaa097..d2455d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "web-scraper-chrome-extension", - "version": "0.5", + "version": "0.5.1", "description": "Web data extraction tool implemented as chrome extension", "scripts": { "lint": "eslint --ext .js src",