Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- DBMS
- Python
- pandas
- 호이스팅
- PostgreSQL
- MariaDB
- analytics4
- 자바
- github
- mssql
- Javascript
- spring
- isNotEmpty
- 오블완
- SQL
- oracle
- 리눅스
- java
- springboot
- Linux
- iBatis
- mysql
- Kibana
- IntelliJ
- 티스토리챌린지
- 404error
- pem
- git
- 명령어
- docker
Archives
- Today
- Total
hanker
JS - github api를 사용하여 git commit.message 불러오기 본문
반응형
var pageNo = 0;
var auth = window.btoa(""); // 인증이 필요한 데이터를 불러올때 사용 ("이름: TOKEN")
$.ajax({
type : "GET", //GET방식
headers : {
Authorization : "Basic " + auth, // BASIC 방식으로 인증
},
url : "https://api.github.com/repos/:owner/:repo/commits?page="+pageNo,
dataType : "json", //JSON데이터 불러옴
success : function(response) {
var array = response;
var max = array.length; // 각 commit 당 count 처리하기 위해서 length 값 구함
for (var i = 0; i < array.length; i++) {
var cal = array[i].commit.author.date;
var result = cal.split('T', 1);
$(".confContainer").append(
"<div class='commitCon'><b class='fntSize'> "
+ max
+ ". "
+ array[i].commit.message
+ "</b></div><div style='color: orange;margin-left: 87%;'>"
+ array[i].commit.author.date
+ "</div>");
= max - 1;
}
},
error : function(e) {
console.log("error");
}
});
url을 설명하자면
:owner는 repository의 관리자 (ex: test)
:repo 는 repository명 (ex: testWeb)
ex) https://api.github.com/repos/test/testWeb/commits?page=0~N
이런식으로 작성하면 된다.
반응형
'JavaScript' 카테고리의 다른 글
Swal - Cannot read property 'then' of undefined 오류 (0) | 2021.01.27 |
---|---|
JQuery - 선택자에 변수 넣기 (0) | 2020.12.16 |
JavaScript - DataTables 파일 다운로드 (0) | 2020.10.05 |
JavaScript - 체크박스 다중선택 value값 (0) | 2020.08.21 |
JavaScript - DataTables 사용법 (0) | 2020.08.18 |