diff --git a/packages/core/admin/admin/src/core/utils/axiosInstance.js b/packages/core/admin/admin/src/core/utils/axiosInstance.js index 5019a02e4e..50823ce207 100644 --- a/packages/core/admin/admin/src/core/utils/axiosInstance.js +++ b/packages/core/admin/admin/src/core/utils/axiosInstance.js @@ -1,10 +1,6 @@ import axios from 'axios'; import { auth } from '@strapi/helper-plugin'; -console.log( - 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' -); - const instance = axios.create({ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL, }); @@ -37,4 +33,20 @@ instance.interceptors.response.use( } ); -export default instance; +const wrapper = {}; + +['request', 'get', 'head', 'delete', 'options', 'post', 'put', 'patch', 'getUri'].forEach( + (methodName) => { + wrapper[methodName] = (...args) => { + console.log( + 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' + ); + + return instance[methodName](...args); + }; + + return wrapper; + } +); + +export default wrapper; diff --git a/packages/core/content-type-builder/admin/src/utils/axiosInstance.js b/packages/core/content-type-builder/admin/src/utils/axiosInstance.js index 3988bfe85b..4154f5d5e2 100644 --- a/packages/core/content-type-builder/admin/src/utils/axiosInstance.js +++ b/packages/core/content-type-builder/admin/src/utils/axiosInstance.js @@ -3,10 +3,6 @@ import { auth } from '@strapi/helper-plugin'; // TODO: remember to pass also the pluginId when you use the new get, post, put, delete methods from fetchClient import pluginId from '../pluginId'; -console.log( - 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' -); - const instance = axios.create({ baseURL: `${process.env.STRAPI_ADMIN_BACKEND_URL}/${pluginId}`, }); @@ -39,4 +35,20 @@ instance.interceptors.response.use( } ); -export default instance; +const wrapper = {}; + +['request', 'get', 'head', 'delete', 'options', 'post', 'put', 'patch', 'getUri'].forEach( + (methodName) => { + wrapper[methodName] = (...args) => { + console.log( + 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' + ); + + return instance[methodName](...args); + }; + + return wrapper; + } +); + +export default wrapper; diff --git a/packages/core/email/admin/src/utils/axiosInstance.js b/packages/core/email/admin/src/utils/axiosInstance.js index 72a342d0ca..8e31af4c28 100644 --- a/packages/core/email/admin/src/utils/axiosInstance.js +++ b/packages/core/email/admin/src/utils/axiosInstance.js @@ -1,10 +1,6 @@ import axios from 'axios'; import { auth } from '@strapi/helper-plugin'; -console.log( - 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' -); - const instance = axios.create({ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL, }); @@ -37,4 +33,20 @@ instance.interceptors.response.use( } ); -export default instance; +const wrapper = {}; + +['request', 'get', 'head', 'delete', 'options', 'post', 'put', 'patch', 'getUri'].forEach( + (methodName) => { + wrapper[methodName] = (...args) => { + console.log( + 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' + ); + + return instance[methodName](...args); + }; + + return wrapper; + } +); + +export default wrapper; diff --git a/packages/core/upload/admin/src/utils/axiosInstance.js b/packages/core/upload/admin/src/utils/axiosInstance.js index 72a342d0ca..8abf430c89 100644 --- a/packages/core/upload/admin/src/utils/axiosInstance.js +++ b/packages/core/upload/admin/src/utils/axiosInstance.js @@ -1,10 +1,6 @@ import axios from 'axios'; import { auth } from '@strapi/helper-plugin'; -console.log( - 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' -); - const instance = axios.create({ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL, }); diff --git a/packages/generators/generators/lib/files/js/plugin/admin/src/utils/axiosInstance.js b/packages/generators/generators/lib/files/js/plugin/admin/src/utils/axiosInstance.js index 8436f5321c..6367534dda 100644 --- a/packages/generators/generators/lib/files/js/plugin/admin/src/utils/axiosInstance.js +++ b/packages/generators/generators/lib/files/js/plugin/admin/src/utils/axiosInstance.js @@ -5,10 +5,6 @@ import axios from 'axios'; import { auth } from '@strapi/helper-plugin'; -console.log( - 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' -); - const instance = axios.create({ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL, }); @@ -41,4 +37,20 @@ instance.interceptors.response.use( } ); -export default instance; +const wrapper = {}; + +['request', 'get', 'head', 'delete', 'options', 'post', 'put', 'patch', 'getUri'].forEach( + (methodName) => { + wrapper[methodName] = (...args) => { + console.log( + 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' + ); + + return instance[methodName](...args); + }; + + return wrapper; + } +); + +export default wrapper; diff --git a/packages/generators/generators/lib/files/ts/plugin/admin/src/utils/axiosInstance.ts b/packages/generators/generators/lib/files/ts/plugin/admin/src/utils/axiosInstance.ts index 8436f5321c..6367534dda 100644 --- a/packages/generators/generators/lib/files/ts/plugin/admin/src/utils/axiosInstance.ts +++ b/packages/generators/generators/lib/files/ts/plugin/admin/src/utils/axiosInstance.ts @@ -5,10 +5,6 @@ import axios from 'axios'; import { auth } from '@strapi/helper-plugin'; -console.log( - 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' -); - const instance = axios.create({ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL, }); @@ -41,4 +37,20 @@ instance.interceptors.response.use( } ); -export default instance; +const wrapper = {}; + +['request', 'get', 'head', 'delete', 'options', 'post', 'put', 'patch', 'getUri'].forEach( + (methodName) => { + wrapper[methodName] = (...args) => { + console.log( + 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' + ); + + return instance[methodName](...args); + }; + + return wrapper; + } +); + +export default wrapper; diff --git a/packages/plugins/i18n/admin/src/utils/axiosInstance.js b/packages/plugins/i18n/admin/src/utils/axiosInstance.js index 72a342d0ca..8e31af4c28 100644 --- a/packages/plugins/i18n/admin/src/utils/axiosInstance.js +++ b/packages/plugins/i18n/admin/src/utils/axiosInstance.js @@ -1,10 +1,6 @@ import axios from 'axios'; import { auth } from '@strapi/helper-plugin'; -console.log( - 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' -); - const instance = axios.create({ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL, }); @@ -37,4 +33,20 @@ instance.interceptors.response.use( } ); -export default instance; +const wrapper = {}; + +['request', 'get', 'head', 'delete', 'options', 'post', 'put', 'patch', 'getUri'].forEach( + (methodName) => { + wrapper[methodName] = (...args) => { + console.log( + 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' + ); + + return instance[methodName](...args); + }; + + return wrapper; + } +); + +export default wrapper; diff --git a/packages/plugins/users-permissions/admin/src/utils/axiosInstance.js b/packages/plugins/users-permissions/admin/src/utils/axiosInstance.js index 72a342d0ca..8e31af4c28 100644 --- a/packages/plugins/users-permissions/admin/src/utils/axiosInstance.js +++ b/packages/plugins/users-permissions/admin/src/utils/axiosInstance.js @@ -1,10 +1,6 @@ import axios from 'axios'; import { auth } from '@strapi/helper-plugin'; -console.log( - 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' -); - const instance = axios.create({ baseURL: process.env.STRAPI_ADMIN_BACKEND_URL, }); @@ -37,4 +33,20 @@ instance.interceptors.response.use( } ); -export default instance; +const wrapper = {}; + +['request', 'get', 'head', 'delete', 'options', 'post', 'put', 'patch', 'getUri'].forEach( + (methodName) => { + wrapper[methodName] = (...args) => { + console.log( + 'Deprecation warning: Usage of "axiosInstance" utility is deprecated and will be removed in the next major release. Instead, use the useFetchClient() hook, which is exported from the helper-plugin: { useFetchClient } from "@strapi/helper-plugin"' + ); + + return instance[methodName](...args); + }; + + return wrapper; + } +); + +export default wrapper;