xyz-data / json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)
MIT License
1 stars 0 forks source link

json-routers & routers #3

Open xyzdata opened 7 years ago

xyzdata commented 7 years ago

json-server

routers

自动映射!


{
    "/api/*": "/$1",
    "/datas/": "/datas/",
    "/datas/:uid": "/datas?uid=:uid",
    "/datas/:key": "/datas?key=:key"
}
xyzdata commented 7 years ago

bad

image

good

id

image

bad

uid ???

image

xyzdata commented 7 years ago

生成随机数据


            // add id to all items
            // http://localhost:7777/datas/ === array
            arr.map(
                (data, index) => {
                    // data.id = ++index;
                    data.id = data.uid
                    return data;
                }
            );

https://github.com/xyzdata/json-server#生成随机数据

image