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
feat: Global interceptors for Http module #9613
Comments
You could write your own interceptor abstraction, or even just use axios in NativeScript. The NativeScript http module is mostly meant to be like the browser/node http module (which also doesn't have interceptors/etc). |
Regarding axios, I tried to import it in my app but I always receive errors. Either from Webpack, or axios itself. |
@dimitrisrk What mistakes do you have? it may be the polyfills, try putting your webpack.config.ts like this: const webpack = require("@nativescript/webpack");
module.exports = (env) => {
webpack.chainWebpack((config) => {
config.resolve.set("fallback", {
os: false,
tty: false,
assert: false,
stream: false,
https: false,
http: false,
url: false,
util: false,
zlib: false,
});
});
webpack.init(env);
return webpack.resolveConfig();
}; |
@vallemar I was aware of polyfills so I used |
For webpack.chainWebpack(config => {
config.resolve.alias.set('axios', 'axios/dist/axios')
})
|
i have new error again ReferenceError : navigator is not defined |
@bobwatcherx post the full stack trace please. |
Is your feature request related to a problem? Please describe.
There are cases one needs interceptors to use the same code for all functions.
Describe the solution you'd like
Global interceptors like the ones in Angular HttpClient, jQuery ajax, or axios would help in such cases.
Additional context
Since Http module is simplified, an approach similar to axios with a single interceptor per case would do.
The text was updated successfully, but these errors were encountered: