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

How to apply middleware only for specific url? #39

Closed
ndeviant opened this issue Jul 23, 2021 · 0 comments
Closed

How to apply middleware only for specific url? #39

ndeviant opened this issue Jul 23, 2021 · 0 comments

Comments

@ndeviant
Copy link

I want to run middleware only for some urls, how can I do it now? I don't really want a separate instance for it, so I'm applying middleware to default object.

Maybe it's a good idea, if you pass your inner functions to caseMiddleware, as a second argument, so we can decide, under which conditions, we'd run it?

    options?.caseMiddleware?.responseTransformer ||
      createCamelResponseTransformer(options),
  ];
  axios.interceptors.request.use(
    options?.caseMiddleware?.requestInterceptor ||
      createSnakeParamsInterceptor(options)
  );

to

    (config) => options?.caseMiddleware?.responseTransformer(config,  createCamelResponseTransformer(options)) ||
      createCamelResponseTransformer(options),
  ];
  axios.interceptors.request.use(
    (config) => options?.caseMiddleware?.requestInterceptor(config, createSnakeParamsInterceptor(options)) ||
      createSnakeParamsInterceptor(options)
  );

but in some more cleaner manner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants