小编tox*_*abs的帖子

如何从github API解析链接头

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解析分页

javascript json jsonp github github-api

26
推荐指数
7
解决办法
1万
查看次数

护照:登录和帐户注册的不同重定向

我在我的应用程序中使用护照模块(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)

node.js express passport.js

9
推荐指数
1
解决办法
6027
查看次数

标签 统计

express ×1

github ×1

github-api ×1

javascript ×1

json ×1

jsonp ×1

node.js ×1

passport.js ×1