Skip to content

Commit

Permalink
feat(github): get commits from github
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyhm committed Sep 13, 2023
1 parent 1ab32d8 commit 8180cf9
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
const express = require('express')
const handlebars = require('express-handlebars');
const handlebars = require('express-handlebars')
const axios = require('axios')

const path = require('path')
const app = express()
const port = 3000

async function fetchGitHubData(){
try {

const response = await axios.get(`https://api.github.com/repos/freddyhm/MyRepoStats/commits?per_page=10`)

if (response.status === 200) {
return response.data
} else {
throw new Error(`Request failed with status: ${response.status}`)
}
} catch (error) {
throw error;
}
}

app.engine('handlebars', handlebars.engine());
async function main() {
try {
let data = await fetchGitHubData()
} catch (error) {
console.error('Error:', error.message)
}
}

main()

app.engine('handlebars', handlebars.engine())
app.set("view engine", "handlebars")
app.set('views', './views');

Expand Down

0 comments on commit 8180cf9

Please sign in to comment.