Set up a simple local server

Create a new folder called fuwu

Then enter CMD in the directory on the page to bring up the terminal

NPM init -y (new package.json)

The package.json file now appears in the FUwu folder.

You can now use VS Code, or if you don’t have it, work on the terminal

Import the FUWU folder into VS Code

Open terminal mode of FUWU

Some dependency packages need to be downloaded

Using the command is

npm i express -s 
Copy the code

Domestic mirror

cnpm i  
Copy the code

Image abroad

npm i 
Copy the code

The installation effect is as follows:

There is also an extra file in the fuWU folder

There is also an extra code in package.json

Now you can create a new app.js file for fuwu

Add code to app.js:

var express = require('express');
var app=express();
/ / data
var obj=[
    {
        name:"bbb".age:18
    },
    {
        name:"aaa".age:20
    }
]

app.get('/goodsList'.function(req,res){
    res.json({
        dataList:obj
    })
})

app.get('/detail'.function(req,res){
    res.json({
        msg:'ss'})})// The number of the server's local host
app.listen('188'.function(){
    console.log("Service started...")})Copy the code

Then you can run the server

Input:

node .\app.js
Copy the code

Operation effect:

The local server is now accessible in the browser

http://localhost:188/goodsList
Copy the code

 

Wechat applets call netease Cloud API

Usage of the netease Cloud API server

First need a netease cloud music server

Server Baidu web disk extraction address:

Link: pan.baidu.com/s/1jXqZfnqn… Extraction code: M3F4

Open CMD in this page and proceed with the following steps

1, Taobao image, foreign server is very slow, install CNPM NPM install -g CNPM — registry.npm.taobao.org

2. Install the corresponding module CNPM install

3. Start the server Node app.js

4, visit http://localhost:3000/toplist/detail

If you have data, you succeed

 

Learn together and make progress together. If there are any mistakes, please comment