What's the Best Way to Use an HTTP Request Command in My Code? or How Do I Properly Structure an HTTP

14 Replies, 635 Views

For JS, `fetch` is great, but axios is even better for http request command stuff. More features, less boilerplate.

```javascript
axios.get('https://api.example.com')
.then(response => console.log(response.data))
.catch(error => console.log(error));
```

Headers? Only if the API demands it. Like for tokens or content-type.

Also, Mozilla’s fetch docs are gold: https://developer.mozilla.org/en-US/docs...sing_Fetch

Messages In This Thread



Users browsing this thread: 1 Guest(s)