Worker to worker request with third party library

Is it possible for one worker to make requests to another worker connected as a service binding using something other than the native fetch?
4 Replies
kian
kianā€¢17mo ago
Iā€™m not too sure what you mean by that - Service Bindings only expose a fetch method.
Polaris
PolarisOPā€¢17mo ago
Yeah. I was just curious if you could use another library like wretch (https://github.com/elbywan/wretch) to make that request from one worker to another. The reason this even came to mind for me is because in a scenario where worker A calls B, and say B could respond with different HTTP status codes, then A will have to check for each one of them in an if statement and decide how to handle each. Other libraries provide better ergonomics for doing this type of operation (wretch for example).
kian
kianā€¢17mo ago
you can probably do it with their polyfills option
const thing = wretch().polyfills({
fetch: env.SVC.fetch
})
const thing = wretch().polyfills({
fetch: env.SVC.fetch
})
might not work exactly like that since I haven't tested it
Polaris
PolarisOPā€¢17mo ago
Thanks for pointing that out, I'll take a look šŸ‘
Want results from more Discord servers?
Add your server