# Worker.prototype.postRequest

**URL:** <https://es.discourse.group/t/worker-prototype-postrequest/2082>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [July 8, 2024, 5:33am UTC](https://es.discourse.group/t/worker-prototype-postrequest/2082 "2024-07-08T05:33:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ihasq](https://avatars.discourse-cdn.com/v4/letter/i/c4cdca/32.png) [@ihasq](https://es.discourse.group/u/ihasq)\
**Post date:** [July 8, 2024, 5:33am UTC](https://es.discourse.group/t/worker-prototype-postrequest/2082/1 "2024-07-08T05:33:31Z")

</div>

[This post doesn't belong here and is definitely not worth reading.]

I think it would be nice to be able to perform Promise-based communication between threads, similar to the service worker's fetch resolution.

There is no special specification for this method name. I am aware that it may be confused with the existing Request object, and believe there is a better name.

Main thread script:

```javascript
const requestWorker = new Worker("./path/to/worker.js");
const workerResponse = await requestWorker.postRequest({ a: 2, b: 3 }); // 5

```

Worker script:

```javascript
self.addEventListener("request", e => {
    const { a, b } = e.data;
    e.respondWith(a + b);
})

```

This may allow you to explicitly return the transferred object after certain processing is completed.

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [July 8, 2024, 6:16am UTC](https://es.discourse.group/t/worker-prototype-postrequest/2082/2 "2024-07-08T06:16:53Z")

</div>

JS doesn’t have workers; you may want WHATWG HTML?

---

<div class="post-metadata">

**Author:** ![ihasq](https://avatars.discourse-cdn.com/v4/letter/i/c4cdca/32.png) [@ihasq](https://es.discourse.group/u/ihasq)\
**Post date:** [July 8, 2024, 6:21am UTC](https://es.discourse.group/t/worker-prototype-postrequest/2082/3 "2024-07-08T06:21:56Z")

</div>

That's true, thanks for reminding me
