Skip to content

Instantly share code, notes, and snippets.

@devotdev
Created December 13, 2024 08:58
Show Gist options
  • Save devotdev/2627671bece2ea1249eb641b70f4bbed to your computer and use it in GitHub Desktop.
Save devotdev/2627671bece2ea1249eb641b70f4bbed to your computer and use it in GitHub Desktop.
Example of a basic API call using axios
// 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