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

config.transport is not documented and its type is not defined #5431

Open
NozomuIkuta opened this issue Jan 5, 2023 · 1 comment
Open

config.transport is not documented and its type is not defined #5431

NozomuIkuta opened this issue Jan 5, 2023 · 1 comment

Comments

@NozomuIkuta
Copy link

Is your feature request related to a problem? Please describe.

While config.transport option is implemented (ref), it's not documented in README. The only reference to it is in some comments to #1175 (e.g. #1175 (comment)).

In addition, AxiosRequestConfig type definition (ref) doesn't include that of transport.

Is config.transport intentionally undocumented?

Describe the solution you'd like

If it's undocumented on purpose, I will do nothing.
Otherwise, I'm glad to submit a PR.

Describe alternatives you've considered

N/A

Additional context/Screenshots

N/A
@AustinFoss
Copy link

I came across this section of the documentation that you're talking about recently: #5444

My reason for searching for this part of axios was I'm looking at recreating the client side half of this example in the browser using javascript: https://github.com/libp2p/go-libp2p-http

tr := &http.Transport{}
tr.RegisterProtocol("libp2p", p2phttp.NewTransport(clientHost))
client := &http.Client{Transport: tr}
res, err := client.Get("libp2p://Qmaoi4isbcTbFfohQyn28EiYM5CDWQx9QRCjDh3CTeiY7P/hello")

What that example is doing is tunneling an HTTP request over a p2p network, using the libp2p protocol. It takes the Go http package and registers a "Transport" using a function of the package called NewTransport() which returns a Roundtripper struct described here: https://github.com/libp2p/go-libp2p-http/blob/master/p2phttp.go#L82

When I was looking for an equivalent to the Go http.client.Transport in the Axios library is how I came across he aforementioned commit here.

The commit describes axios.request('url', config), config. transport, as type any. So as you pointed out, it's not actually part of the AxiosRequestConfig

I hope this is a feature of the axios lib; I'll look for other means of achieving what I want. Compiling the example client to WASM is an option I think but would rather have a JS native way to do this.

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