首页>文档>边缘计算>直接返回JSON

直接返回JSON

// 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));
});
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
QQ客服
  • QQ176363189 点击这里给我发消息
旺旺客服
  • 速度网络服务商 点这里给我发消息
电子邮箱
  • sudu@yunjiasu.cc
微信客服
  • suduwangluo