Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forceUpdate does not work with axios 0.19 #54

Closed
iaarnio opened this issue Jun 14, 2019 · 6 comments
Closed

forceUpdate does not work with axios 0.19 #54

iaarnio opened this issue Jun 14, 2019 · 6 comments

Comments

@iaarnio
Copy link
Contributor

iaarnio commented Jun 14, 2019

I'm using request options to force axios-extensions to update cache entries when needed.

This has been working fine with axios 0.18.0 (and 0.18.1) but when I recently updated to 0.19.0 I noticed that forceUpdate does not have effect anymore. Data is still returned from cache.

package.json:

    "axios": "^0.19.0",
    "axios-extensions": "^3.0.6",

Code:

const requestOptions = {
  params: {
    _format: 'json',
  },
  forceUpdate: cacheIsBypassed,
};
const {data} = await cachedAxios.get(requestUrl, requestOptions);

For now the resolution was reverting back to 0.18.1 but for going forward it would be good to make axios-extensions to work fully with axios 0.19 too.

@iaarnio
Copy link
Contributor Author

iaarnio commented Jun 14, 2019

Tried also bumping axios version in axios-extensions' package.json to 0.19.0.

Then 6 tests failed:

  ✔ utils › buildSortedURL › build a simple url without params
  ✔ utils › buildSortedURL › build a simple url with params
  ✔ utils › buildSortedURL › build a url which already had a query string with params
  ✔ utils › isCacheLike › a object with specified method will be regard as cache
  ✖ cacheAdapterEnhancer › cache adapter shouldn't cache request with noCacheFlag
  ✖ cacheAdapterEnhancer › disable default cache switcher
  ✖ cacheAdapterEnhancer › use a custom cache with request individual config
  ✖ cacheAdapterEnhancer › cache will be removed when request error
  ✖ cacheAdapterEnhancer › request will refresh the cache with forceUpdate config
  ✔ cacheAdapterEnhancer › cache adapter should cache request without noCacheFlag
  ✔ throttleAdapterEnhancer › throttle adapter shouldn`t do anything when a non-get request invoked
  ✖ throttleAdapterEnhancer › cache will be removed when request error
  ✔ throttleAdapterEnhancer › use a custom cache for throttle enhancer
  ✔ throttleAdapterEnhancer › throttle adapter should cache request in a threshold seconds (1s)

  6 tests failed

Btw had to also add "dom" to typescript libraries to make it run for me:

/tmp/axios-extensions (master ✘)✹✭ ᐅ g diff
diff --git a/package.json b/package.json
index dcf2412..57b5e17 100755
--- a/package.json
+++ b/package.json
@@ -50,7 +50,7 @@
     "@types/node": "^10.0.3",
     "@types/sinon": "^4.3.1",
     "ava": "^0.25.0",
-    "axios": "^0.18.0",
+    "axios": "^0.19.0",
     "codecov": "^3.1.0",
     "husky": "^0.14.1",
     "nyc": "^13.1.0",
diff --git a/tsconfig.json b/tsconfig.json
index c926720..9f618db 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -6,7 +6,7 @@
        "module": "commonjs",
        /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
        "lib": [
-         "es2015"
+         "es2015", "dom"
        ],
        /* Specify library files to be included in the compilation:  */
        // "allowJs": true,                       /* Allow javascript files to be compiled. */

@kuitos
Copy link
Owner

kuitos commented Jun 16, 2019

Seems that was a bug/breaking change with axios v0.19.0, see axios/axios#2207

Maybe I should add a comment on README about this before the bug fixed by axios.

@jeeeez
Copy link

jeeeez commented Jul 22, 2019

Seems that was a bug/breaking change with axios v0.19.0, see axios/axios#2207

Maybe I should add a comment on README about this before the bug fixed by axios.

@kuitos catch you!

@kuitos kuitos closed this as completed Dec 2, 2019
@insanity54
Copy link

insanity54 commented Feb 21, 2020

axios/axios#2207 is merged. Is the note about 0.19 incompatibility in README.md still relevant?

@kuitos
Copy link
Owner

kuitos commented Feb 21, 2020

The note is point to the exact version 0.19.0, I think it still makes sense.

@insanity54
Copy link

I understand, thank you.

egesu added a commit to kodilan-com/frontend that referenced this issue Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants