Skip to content

fetch error NetworkError when attempting to fetch resource #53

@tiechui1994

Description

@tiechui1994

code:

async function app(event) {
    console.log(event)
    try {
        const response = fetch("http://jsonplaceholder.typicode.com/users", {
            method: "GET",
        })
        console.info("success", response)
        return response
    } catch (e) {
        console.warn("panic", e)
        return new Response(JSON.stringify({
            error: e.stack
        }))
    }
}

addEventListener('fetch', (event) => {
    event.respondWith(app(event).then(r => {
        console.info("request success", r)
        return r
    }).catch(e => {
        console.warn("request error", e)
        return new Response(e.message || "Server Error", {
            status: e.status || 500,
        });
    }));
});

curl 'http://localhost:3006/current'

NetworkError when attempting to fetch resource

@godronus Hello, Could you help me look into this issue? Thanks a lot

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions