云端数据,一行 fetch
每个项目自带一个数据接口。排行榜、留言板、投票、游戏存档,写几行 JS 就能存到服务器上。项目 Key 复制就能用。
// 读
const res = await fetch('/api/v1/data/score');
if (res.ok) render((await res.json()).data.value);
// 写
await fetch('/api/v1/data/score', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ value: scores })
});