Use text() for both request and response parsing
- request.json() may not be available in wws - Parse request body manually with JSON.parse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,18 @@ const handler = async (request) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const body = await request.json()
|
// Use text() and parse manually - json() may not be available in wws
|
||||||
|
const bodyText = await request.text()
|
||||||
|
let body
|
||||||
|
try {
|
||||||
|
body = JSON.parse(bodyText)
|
||||||
|
} catch (e) {
|
||||||
|
let response = new Response(JSON.stringify({ error: 'Invalid JSON body' }))
|
||||||
|
response.headers.set('Content-Type', 'application/json')
|
||||||
|
response.headers.set('Access-Control-Allow-Origin', '*')
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
const message = body.message
|
const message = body.message
|
||||||
const project_id = body.project_id
|
const project_id = body.project_id
|
||||||
const user_id = body.user_id
|
const user_id = body.user_id
|
||||||
@@ -45,7 +56,7 @@ const handler = async (request) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Use text() and parse manually (json() may not be available in wws)
|
// Use text() and parse manually
|
||||||
const responseText = await n8nResponse.text()
|
const responseText = await n8nResponse.text()
|
||||||
let result
|
let result
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user