jsonserver 环境搭建及使用方法

1.安装npm

2.安装json-server

3.使用

1.安装npm

下载node.js,地址:https://nodejs.org/zh-cn/

这里的基础知识,比如:配置淘宝仓库,配置npm的目录等,不描述,这是基础知识。

2.安装json-server

安装命令:npm install json-server --g

3.使用

新增目录:d:\json,并新建json文件:data.json

在该目录执行命令:

第一步:json-server --watch --port 5001 data.json     

            注意:对数据的格式,需要严格按照要求,比如:必须是{}包起来,然后配置数据源。

第二步:浏览器,访问地址:http://localhost:5001/students            这里是操作数据源:students,对于json文件的students,一一对应的。

 1.查询数据:http://localhost:5001/students

  2.删除数据:

  3.新增数据

   4.修改数据

参考链接:https://blog.csdn.net/qq_36538012/article/details/103161017

天生我材必有用,千金散尽还复来
原文地址:https://www.cnblogs.com/ligenyun/p/15562938.html