Node base module clearing list

URI module

这里写图片描述

URL: Uniform resource locator – URL, is a subset of URI. English, alphanumeric URI: Uniform Resource Identifier – string format specification.

url provides a total of three methods, respectively url.parse() url.format() url.resolve()

const url = require("url")
const myurl = 'http://imooc.com:8080/course/list?from=anikin&course=node#floor1'
const res = url.parse(myurl,truetrue)

// http://www.baidu.com/list
const res2 = url.resolve('http://www.baidu.com','/list')  

res The result is a table red is the scope of two parameters true 这里写图片描述

qs module

qs A package managed by the npmWarehouse can be installed via the npm install qs or yarn add qs command. Mainly in the front end, used for the synthesis of json objects or parsing the value of the parameters in the uri

  1. qs.parse() // When it comes to url Use the uri module to be more efficient

  2. qs.stringify()Send the object into a URL form, and splicing with &,

JSON.stringify

const mydata = {name:'anikin',age:23}
console.log( Qs.stringify(mydata)) // name=anikin&age=23
console.log(JSON.stringify(mydata) ) // "{"name":"anikin","age":23}"