How To Use Axios with JavaScript | DigitalOcean

PHOTO EMBED

Tue Jun 15 2021 11:49:35 GMT+0000 (Coordinated Universal Time)

Saved by @swastik #javascript

// ...

const BASE_URL = 'https://jsonplaceholder.typicode.com';

const getTodoItems = async () => {
  try {
    const response = await axios.get(`${BASE_URL}/todos?_limit=5`);

    const todoItems = response.data;

    console.log(`GET: Here's the list of todos`, todoItems);

    return todoItems;
  } catch (errors) {
    console.error(errors);
  }
};
content_copyCOPY

https://www.digitalocean.com/community/tutorials/js-axios-vanilla-js