PluginProbe
Extendify / 0.11.1
Extendify v0.11.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Assist / api / axios.js

axios.js in Extendify 0.11.1, at src/Assist/api/axios.js

40 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import axios from 'axios'
2
3 const Axios = axios.create({
4 baseURL: window.extAssistData.root,
5 headers: {
6 'X-WP-Nonce': window.extAssistData.nonce,
7 'X-Requested-With': 'XMLHttpRequest',
8 'X-Extendify-Assist': true,
9 'X-Extendify': true,
10 },
11 })
12 Axios.interceptors.request.use(
13 (request) => {
14 // Thiis is here to limit network requests when encountering aggressive rate limiting
15 const q = new URLSearchParams(window.location.search)
16 if (['onboarding'].includes(q.get('extendify'))) {
17 throw new axios.Cancel(
18 'Assist is not available while running Launch',
19 )
20 }
21 return checkDevMode(request)
22 },
23 (error) => error,
24 )
25 Axios.interceptors.response.use((response) =>
26 Object.prototype.hasOwnProperty.call(response, 'data')
27 ? response.data
28 : response,
29 )
30
31 const checkDevMode = (request) => {
32 request.headers['X-Extendify-Assist-Dev-Mode'] =
33 window.location.search.indexOf('DEVMODE') > -1
34 request.headers['X-Extendify-Assist-Local-Mode'] =
35 window.location.search.indexOf('LOCALMODE') > -1
36 return request
37 }
38
39 export { Axios }
40