github API在http链接头中发送json结果的分页数据:
Link: <https://api.github.com/repos?page=3&per_page=100>; rel="next",
<https://api.github.com/repos?page=50&per_page=100>; rel="last"
Run Code Online (Sandbox Code Playgroud)
因为github API不是唯一使用这种方法的API(我认为)我想问一下是否有人有一个有用的小片段来解析链接头(并将其转换为数组),以便我可以将它用于我的js app.
我搜索了一下,但没有发现如何从json API解析分页
我在我的应用程序中使用护照模块(github身份验证),我想根据操作重定向...我检查它是否只是正常登录或用户是否第一次登录.
passport.use(new GitHubStrategy({
clientID: conf.github.app_id,
clientSecret: conf.github.app_secret,
callbackURL: conf.github.callback_url
},
function(accessToken, refreshToken, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
// To keep the example simple, the user's GitHub profile is returned to
// represent the logged-in user. In a typical application, you would want
// to associate the GitHub account with a user record in your database,
// and return that user instead.
Models_User.findOrCreateUser(profile, function(msg){
console.log("auth type:" + msg);
});
return done(null, profile);
});
}
)); …Run Code Online (Sandbox Code Playgroud)