muslax
muslax
CDCloudflare Developers
Created by muslax on 3/8/2023 in #workers-help
How to import XML file as js module in Workers? Is it possible?
My data is scattered in more than 100 XML files, and converting them to JSON is definitely tedious. Will be sweet if I can just import them and then utilize them using xml processors.
5 replies
CDCloudflare Developers
Created by muslax on 1/25/2023 in #workers-help
Cannot POST to worker service
My worker A (using Hono) has GET and POST endpoint like so:
app.get('/test', (c) => {
return c.text('GET /test')
})

app.post('/test', (c) => {
return c.text('POST /test')
})
app.get('/test', (c) => {
return c.text('GET /test')
})

app.post('/test', (c) => {
return c.text('POST /test')
})
In my worker B the code below successfully connect to worker A:
app.get('/test', async (c) => {
return await c.env.WORKER_A.fetch(c.req) // 'GET /test'
})
app.get('/test', async (c) => {
return await c.env.WORKER_A.fetch(c.req) // 'GET /test'
})
But when B tries to talk to A using POST:
app.post('/test', async (c) => {
return await c.env.WORKER_A.fetch(c.req)
})
app.post('/test', async (c) => {
return await c.env.WORKER_A.fetch(c.req)
})
it always error:
Trace: TypeError: Cannot construct a Request with a Request object that has already been used.
at new Request (/Users/polt/aces-workers/auth-test/node_modules/undici/lib/fetch/request.js:488:15)
at new Request (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/core/src/standards/http.ts:393:13)
at upgradingFetch (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/web-sockets/src/fetch.ts:21:19)
at WebSocketPlugin.<anonymous> (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/core/src/standards/http.ts:891:21)
[TRUNCATED}
Trace: TypeError: Cannot construct a Request with a Request object that has already been used.
at new Request (/Users/polt/aces-workers/auth-test/node_modules/undici/lib/fetch/request.js:488:15)
at new Request (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/core/src/standards/http.ts:393:13)
at upgradingFetch (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/web-sockets/src/fetch.ts:21:19)
at WebSocketPlugin.<anonymous> (/Users/polt/aces-workers/auth-test/node_modules/@miniflare/core/src/standards/http.ts:891:21)
[TRUNCATED}
8 replies