報(bào)錯(cuò):json-server Type of "xxx" (string) is not supported.
使用json-server mock數(shù)據(jù)時(shí)遇到的問(wèn)題:
當(dāng)在db.json中定義
{
"name": "Jack"
}
會(huì)報(bào)錯(cuò): json-server Type of "name" (string) is not supported.
原因與json-server的工作方式有關(guān)
直接暴露在JSON對(duì)象根目錄下的每個(gè)鍵都被視為json-server中的單獨(dú)URL。
需要使用對(duì)象或數(shù)組對(duì)象