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

Add an HttpStack for Axios #570

Open
SpecLad opened this issue Mar 29, 2023 · 7 comments
Open

Add an HttpStack for Axios #570

SpecLad opened this issue Mar 29, 2023 · 7 comments

Comments

@SpecLad
Copy link

SpecLad commented Mar 29, 2023

Is your feature request related to a problem? Please describe.
In our project we mostly use Axios for making HTTP queries, with some default settings configured globally (e.g. default HTTP headers). We also use tus-js-client, but since it uses its own HTTP stack, we have to replicate the default Axios settings into their tus-js-client equivalents. This causes code duplication, and it's easy to forget to replicate a setting, which leads to divergent behavior.

Describe the solution you'd like
It would be nice if I could write something like this and have tus-js-client work through Axios:

import Axios from 'axios';

const upload = new tus.Upload(file, { httpStack: tus.AxiosHttpStack(Axios), ... });

// or
const axiosInstance = Axios.create({ ... });
const upload = new tus.Upload(file, { httpStack: tus.AxiosHttpStack(axiosInstance ), ... });

That way, all Axios settings would automatically be applied.

Describe alternatives you've considered
I'm aware that I could just implement this AxiosHttpStack on my side. However, Axios is a popular library, so I think many users could find this useful if it was included in tus-js-client.

Can you provide help with implementing this feature?
In principle, yes, although I don't know when I'll be able to get around to it.

Additional context
N/A

@Acconut
Copy link
Member

Acconut commented Mar 31, 2023

What config settings in Axios could be set that way? From https://axios-http.com/docs/config_defaults, I feel like only a base URL and headers can be configured.

In general, I do see a use for this, but don't think we will have time ourselves to work on this. So if anybody else is interested, we are happy to assist.

@SpecLad
Copy link
Author

SpecLad commented Mar 31, 2023

@Acconut
Copy link
Member

Acconut commented Mar 31, 2023

Ok, then let's see if somebody wants to tackle this.

@ArunBohra12
Copy link
Contributor

Hello, @Acconut. I would love to take this issue and work on it.

@Acconut
Copy link
Member

Acconut commented Jun 27, 2023

That's great to hear! Let me know if you need some help getting started. It should be as simple as copying https://github.com/tus/tus-js-client/blob/main/lib/browser/httpStack.js and replacing XMLHttpRequest with Axios.

@kalemi19
Copy link

kalemi19 commented Oct 3, 2024

Curious to see this implemented

@Acconut
Copy link
Member

Acconut commented Oct 4, 2024

@kalemi19 Let me know if you are interested in helping with this

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

4 participants