loading
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const superagent = require('superagent')
// we use superagent to request from server
superagent
	.get('https://api.bilibili.com/x/web-interface/archive/stat')
	// send GET requests to url
	.query({aid:26763233})
	// here goes the parameters for the request
  // we could also use https://api.bilibili.com/x/web-interface/archive/stat?aid=26763233
  // as the get url and leave this query function no arguments
  // query function will take the dict of parameters
  // and append the to the url as ?aid=26763233
	.then(res => res && console.log(res.body))
	// excute console.log() if the response is successfull
  // console.log() prints the results in the terminal
	.catch(err => console.error(err))
	// catch error and print it in terminal if it fails