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 = ''
const res = url.parse(myurl,truetrue)

const res2 = url.resolve('','/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 &,


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