Vue recommends that using Axios for HTTP requests. As I know, Axios use http1.1 protocol, but I want to use http2.0, how should I do? h2 has been a build-in module in nodejs at server-side, so I need h2 in vue as a client.
The HTTP/2 connection should be transparent for your browser application. You just need to make sure your server and browser support HTTP/2
When both of your server and browser support HTTP/2 your browser's XHR will use HTTP/2. You don't need to do any special setup in Vue.js
For Axios, HTTP/2 support problem only happens in the server-side. Because it is using the following adapter which calls Node.js' HTTP and HTTPS module.
https://github.com/axios/axios/blob/master/lib/adapters/http.js
There is already a pull-request for HTTP/2 support. You can try it if you want Axios HTTP/2 support in server-side
But in client-side it will use browser API - XMLHttpRequest which will follow the browser behaviour
https://github.com/axios/axios/blob/master/lib/adapters/xhr.js
© 2022 - 2024 — McMap. All rights reserved.