2022-04-28

How would I consume the body of a put request from a web worker

I want to consume data sent through a put request in a web worker. How would I do so?

this the part in my code where I am trying to handle the put request

if (method === 'put') {
    var data = await event.request.arrayBuffer(); // is this how I could consume the request?
    await updateTree(path); // this is successful
    await put(path, data); // this isnt written
    return new Response('', { // the request still finishes
        headers: {
            'content-length': 0
        },
        status: 201
    });
}

path: the request path

event: the fetch listener event

put: a function that uses the indexeddb api to store data, this function has been tested and works



No comments:

Post a Comment