1. postman
2. json-server
- Json – server installation
npm install json-server
Copy the code
- Create virtual interface data db.json
// db.json
{
// Interface access path/getInfo
"getinfo": {
"success": true."msg": "Request successful"."code": 0."data": [{"name": "Tom"."age": 18
},
{
"name": "Tony"."age": 20}},// Interface access path /user or /user/1 accesses deep data
"user": [{"id": 0."name": "Tony"
},
{
"id": 1."name": "Tom"}}]Copy the code
- Start the mock service
Json --watch db. Json --port 9090Copy the code
3. RAP
- Create account
Visit RAP, register an account and log in
- Create a warehouse
- Enter the repository to create the interface
- Configure interface parameters and return parameter rules
Regular grammar reference
- Save to access
Click to get access address information
4. mock.js
- Install mockjs
npm install mockjs
Copy the code
- Create server.js and introduce MockJS
// server.js
/ / the introduction of express
const express = require('express');
/ / introduce mockjs
const Mock = require('mockjs')
// Prepare service objects
const app = express()
// Listen for routes
app.get('/getinfo'.(req, res) = > {
// Prepare random data
var data = Mock.mock({
'list|1-20': [{
'name|3-5': /[a-z][A-Z]/.'age|10-15': 15.'gender|1': true,
}]
})
res.end(JSON.stringify(data));
})
// Start the service
app.listen(3000)
Copy the code
- Start the service
node server.js
Copy the code
5.YAPI
address