0
点赞
收藏
分享

微信扫一扫

Nuxt服务端渲染-Json-server api服务搭建

邯唐情感 2022-07-27 阅读 78


​​https://github.com/typicode/json-server#paginate​​

首先全局安装

cnpm install json-server -g
// mac下执行
sudo cnpm install json-server -g

在目录下创建一个server文件夹,将data.json文件放在里面

{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}

Nuxt服务端渲染-Json-server api服务搭建_ico

cd server 进入server文件夹

执行下列命令

json-server --watch data.json --port 3002

数据启动成功

Nuxt服务端渲染-Json-server api服务搭建_github_02

​​http://localhost:3002/jokes?_page=2&_limit=5​​ 表示第2页,一页5条

http://localhost:3002/jokes?&q=why 表示查询why这个字段

这说明接口已经可以使用了

 

 

 

 

 

 

 

 

 

 

 

 

 

举报

相关推荐

0 条评论