작은 웹 앱에 github api를 사용하고 어느 시점에 the pagination에 link header을 가져와야합니다.Github API는 아약스로 링크 헤더를 얻습니다.
최종 목표는 리포지토리 당 커밋의 총 수를 얻는 것입니다. 나는 python script을 발견하고이를 JavaScript에 적용하려고했습니다.
getData = $.getJSON('https://api.github.com/repos/'+user+'/'+repo+'/commits?callback=?', function (commits){
console.log(getData.getResponseHeader('link'))
// will return null
console.log(getData.getAllResponseHeaders('link'))
// will return an empty string
console.log(commits)
// will successfuly return my json
});
user
및 repo
는 각각 사용자 이름과 자신의 repo 이름 난 단지 자바 스크립트를 사용할 수 있도록 그것은 Github에서의 페이지입니다
있습니다. 당신이 API를 호출하는 JSONP를 사용하는 경우 http://developer.github.com/v3/#json-p-callbacks
기본적으로, 당신은 Link
헤더를받지 않습니다,하지만 당신은 대신에 동일한 정보를 얻을 것이다 :
완벽, 감사 –