Try ```js // In Pages Function export async function onRequestPost(context) { console.log(await co
Try
// In Pages Function
export async function onRequestPost(context) {
console.log(await context.request.json());
// Do something else
}Request type doesn't have a parsed body. This allows you to skip reading it if you don't actually need to parse it yourself. The await request.json() part tells it to begin pulling the body in, and parse it as JSONfunctions/hello.ts can be fetched like fetch('/hello') in my fullstack app? http://127.0.0.1:8787/hello but fetching it gives an error Invalid URL string. checkURLwrangler pages dev dist/. Same using wrangler pages functions build. This last says wrangler pages deploy dist/ --project-name my-project.importing depencies in as necessarywrangler.toml? Feel free to replace the key with a random value..dev.vars fileaddEventListener_routes.json (https://developers.cloudflare.com/pages/functions/routing/#create-a-_routesjson-file) is supported in Functions Advanced mode ?./_worker.js folder with a index.ts seems to be automatically transpiled and it works. But is this expected behavior?11:31:45.603 Found Functions directory at /functions. Uploading.
11:31:46.776 ✘ [ERROR] 26 error(s) and 0 warning(s) when compiling Worker.
...
11:31:46.810 [[route]].ts:6:30: ERROR: Could not resolve "hono"
11:31:46.810 [[route]].ts:9:23: ERROR: Could not resolve "hono/cloudflare-pages"
11:31:46.810 [[route]].ts:10:21: ERROR: Could not resolve "hono/html"import/
functions/
index.js
thing.js
... etc
/public
index.html
index.css
... etc
package.jsonwrangler.toml.dev.varsaddEventListener_routes.jsonAdvanced mode./_worker.jsindex.tsconst publishableKey = env.STRIPE_PUBLISHABLE_KEY[wrangler:err] TypeError: Cannot read properties of undefined (reading 'STRIPE_PUBLISHABLE_KEY')export async function onRequestGet(res, env, ctx) {
// Code
}name = "name"
pages_build_output_dir = "./dist"
compatibility_date = "2023-10-21"
compatibility_flags = ["nodejs_compat"]
[vars]
STRIPE_PUBLISHABLE_KEY = "sdfsf"
STRIPE_SECRET_KEY = "sdfsfds"
STRIPE_WEBHOOK_SECRET = "asdad"
[env.production.vars]
STRIPE_PUBLISHABLE_KEY = "sdfsf"
STRIPE_SECRET_KEY = "sdfsfds"
STRIPE_WEBHOOK_SECRET = "asdad"addEventListener('fetch', event => {
event.respondWith(onRequestGet(event))
})
export async function onRequestGet(event) {
const { env } = event
// other code
}addEventListener('fetch', event => {
event.respondWith(onRequestPost(event.request, event.env))
})
export async function onRequestGet(req,env) {
const requestBody = await req.json();
const key = env.STRIPE_SECRET_KEY;
// other code
}addEventListener('fetch', event => {
event.respondWith(onRequestPost(event))
})
export async function onRequestGet(event) {
const { request, env } = event;
const requestBody = await request.json();
const key = env.STRIPE_SECRET_KEY;
// other code
}