Skip to content

Instantly share code, notes, and snippets.

@dmdboi
Last active December 1, 2020 09:02
Show Gist options
  • Save dmdboi/816a69de41976c1ae52d109883e79897 to your computer and use it in GitHub Desktop.
Save dmdboi/816a69de41976c1ae52d109883e79897 to your computer and use it in GitHub Desktop.
A Netlify function to return your public GitHub repositories.
const axios = require("axios");
exports.handler = async event => {
try {
let username = "" // Your Github Username
let repos = await axios({
method: "GET",
url: `https://api.github.com/users/${username}/repos`
}).then(res => {
return res.data;
});
return {
statusCode: 200,
body: JSON.stringify(repos)
};
} catch (e) {
return {
statusCode: 404,
body: JSON.stringify(e)
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment