-
-
Save devotdev/2627671bece2ea1249eb641b70f4bbed to your computer and use it in GitHub Desktop.
Example of a basic API call using axios
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// api.js | |
const axios = require('axios'); | |
const fetchData = async (url) => { | |
try { | |
const response = await axios.get(url); | |
return response.data; | |
} catch (error) { | |
throw error; | |
} | |
}; | |
module.exports = fetchData; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment