mock data a year ago
如果你还在为mock data而烦劳,那么可以尝试 DummyJSON
Example: 获取所有
fetch('https://dummyjson.com/products')
.then(res => res.json())
.then(json => console.log(json));
OR
const res = await fetch('https://dummyjson.com/products');
const json = await res.json();
console.log(json);
Example: 获取一页: 获取单页是靠控制limit和skip这2个变量实现的
fetch('https://dummyjson.com/products?limit=10&skip=10&select=title,price')
.then(res => res.json())
.then(console.log);