parse-links

2019-05-17 admin

parse-links是什么

什么是parse-links,Parse the Links header format and return a javascript object.

parse-links使用教程帮助文档

Parse a Links header into a javascript object.

I’ll no longer maintain this repository. li is a fork from this repository and allows parse and stringify.

Install

npm install parse-links

Usage

var parseLinks = require('parse-links');
var someLinksHeader = '</api/users?page=0&per_page=2>; rel="first", ' +
                      '</api/users?page=1&per_page=2>; rel="next", ' +
                      '</api/users?page=3&per_page=2>; rel="last"';

console.log(parseLinks(someLinksHeader));

// This will print:
// { 
//   first: '/api/users?page=0&per_page=2',
//   next: '/api/users?page=1&per_page=2',
//   last: '/api/users?page=3&per_page=2' 
// }

License

MIT!

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-65207.html

文章标题:parse-links

回到顶部