// JSON 内容
const someJSON = {
result: ['some', 'results'],
errors: null,
msg: 'this is a DuEdge generated json',
};
async function handleRequest(request) {
const init = {
headers: {
'content-type': 'application/json;charset=UTF-8',
},
};
// 直接返回 JSON
return new Response(JSON.stringify(someJSON), init);
}
addEventListener('fetch', event => {
return event.respondWith(handleRequest(event.request));
});
直接返回JSON
暂无讨论,说说你的看法吧