我正在使用XMLHttpRequest
从GitHub API请求资源。从the response is paginated开始,我想使用提供的Link
标头。
在响应回调中记录request.getResponseHeader("link")
时,我得到null
(如果没有分页)或类似内容:
<https://api.github.com/repositories/14173222/forks?sort=stargazers&per_page=100&page=2>; rel="next", <https://api.github.com/repositories/14173222/forks?sort=stargazers&per_page=100&page=4>; rel="last"
是否有一种无需解析就可以导航返回的String的简便方法?
类似于request.getResponseHeader("link").get("next")
的东西,它将返回https://api.github.com/repositories/14173222/forks?sort=stargazers&per_page=100&page=2
我的实际目标是提取下一页的编号(例如,在这里,我想要一个返回2
的函数,因为它是要请求的下一页)。
答案 0 :(得分:0)
我不会将其标记为可接受的答案,因为它不能完全回答问题,但这仍然是我最终要做的事情:
order-0, order1, etc.