Closed jfsiii closed 2 years ago
The xsrf cookie/header can definitely be a plugin, good catch 🙂 im not at a laptop right now but ill take a look at that tomorrow
Published and extracted the xsrf stuff to a plugin 🙂
Would love to see how youre using the api client btw, if it happens to be open source.
Summary
If you try to use this in non-browser runtimes, like node and Cloudflare Workers, you'll get an
Uncaught ReferenceError: window is not defined
errorUse
globalThis
instead ofwindow
and the code will use the global fetch if it's available; just like in the browserOut of scope
There's another blocker for using outside the browser. https://github.com/thepassle/app-tools/blob/630152938fb9d94b4f78c160ddfd089e40625fb3/api/index.js#L1 uses
document
I worked around this locally by commenting out https://github.com/thepassle/app-tools/blob/399532e22113987436980c6fb5ed0c4721fa1430/api/index.js#L92 and https://github.com/thepassle/app-tools/blob/399532e22113987436980c6fb5ed0c4721fa1430/api/index.js#L101
Perhaps
getCookie
could become a plugin, param, or some other way the consumer could say how to access/manage the cookie?