Skip to content

Instantly share code, notes, and snippets.

@charlesdrews
Created August 14, 2019 19:55
Show Gist options
  • Save charlesdrews/87d0d321e55599df28f36d9eaf92f317 to your computer and use it in GitHub Desktop.
Save charlesdrews/87d0d321e55599df28f36d9eaf92f317 to your computer and use it in GitHub Desktop.
/**
* Retrieve the "next" url from the Link header of the API's response
* @param linkHeaderValue
*/
private getNextUrlFromLinkHeader(linkHeaderValue: string): string {
const links = linkHeaderValue.split(",");
for (const link of links) {
if (link.indexOf("rel=\"next\"") > -1) {
const url = link.split("; ")[0];
return url.replace(/[<>]/g, "");
}
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment