mediamonks / frontend-coding-standards

Media.Monks - Frontend Coding Standards
60 stars 23 forks source link

Handling HTTP requests #24

Open MickJasker opened 3 years ago

MickJasker commented 3 years ago

What should the standard be for handling HTTP requests in your project?

There are multiple options:

Axios

Pros

Cons

Size: 13.4kB minified (https://bundlephobia.com/result?p=axios@0.20.0)

Fetch

Pros

Cons

Size: native

Redaxios

Pros

Cons

Size: 1.9kB minified (https://bundlephobia.com/result?p=redaxios@0.3.0)

psimk commented 3 years ago

redaxios also implements the AbortController, so we will finally be able to cancel our requests. This will be especially useful in React, where we could cancel pending requests, whenever the component unmounts.