You need to enable JavaScript to run this app.
导航

边缘JSON处理

最近更新时间2023.12.20 19:13:37

首次发布时间2023.02.15 19:04:51

以下示例展示了如何利用JavaScript的JSON能力在边缘回复JSON数据。

addEventListener("fetch", event => {
  const data = {
    hello: "world"
  }
  const json = JSON.stringify(data);
  return event.respondWith(
    new Response(json, {
      headers: {
        "content-type": "application/json;charset=UTF-8"
      }
    })
  )
})