What is Fetch?
Fetch is a tool in Javascript that allows website to communicate to a server to get or send information
Why Fetch?
When you shop online,fetch retrieves product details or sends your order to server
Example
<script> fetch("https://fakestoreapi.com/products") .then ((res) => res.json()) .then (jsonresponse) => console.log(jsonresponse)) .catch ((rej) => rej.json()) </script>
What is Axios?
- Axios is an external library
- Axios is a promise-based HTTP Client for node.js and the browser
Example
axios.get("https://fakestoreapi.com/products") .then (res => { console.log(res); }) .catch (err => { console.error(err); })
Top comments (0)