@mpxjs/api-proxy 2.8.49 → 2.8.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/api-proxy",
3
- "version": "2.8.49",
3
+ "version": "2.8.58",
4
4
  "description": "convert miniprogram API at each end",
5
5
  "module": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -39,5 +39,5 @@
39
39
  "dependencies": {
40
40
  "axios": "^0.21.1"
41
41
  },
42
- "gitHead": "b399e81951df7094fb0a494ae877bcf4e6a2985b"
42
+ "gitHead": "42e08109b8890516ea12d47598f42e2c0a9f4682"
43
43
  }
@@ -39,7 +39,17 @@ function request (options = { url: '' }) {
39
39
  headers: header,
40
40
  responseType,
41
41
  timeout,
42
- cancelToken: source.token
42
+ cancelToken: source.token,
43
+ transitional: {
44
+ // silent JSON parsing mode
45
+ // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour)
46
+ // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json')
47
+ silentJSONParsing: true, // default value for the current Axios version
48
+ // try to parse the response string as JSON even if `responseType` is not 'json'
49
+ forcedJSONParsing: false,
50
+ // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
51
+ clarifyTimeoutError: false
52
+ }
43
53
  }
44
54
 
45
55
  if (method === 'GET') {
@@ -49,7 +59,7 @@ function request (options = { url: '' }) {
49
59
 
50
60
  const promise = axios(rOptions).then(res => {
51
61
  let data = res.data
52
- if (responseType === 'text' && dataType === 'json') {
62
+ if (dataType === 'json' && typeof data === 'string') {
53
63
  try {
54
64
  data = JSON.parse(data)
55
65
  } catch (e) {
@@ -81,7 +81,11 @@ function navigateTo (options = {}) {
81
81
  function navigateBack (options = {}) {
82
82
  const router = global.__mpxRouter
83
83
  if (router) {
84
- const delta = options.delta || 1
84
+ let delta = options.delta || 1
85
+ const stackLength = router.stack.length
86
+ if (stackLength > 1 && delta >= stackLength) {
87
+ delta = stackLength - 1
88
+ }
85
89
  router.__mpxAction = {
86
90
  type: 'back',
87
91
  delta