fix: added check for document, so redaxios will not break in Node#57
fix: added check for document, so redaxios will not break in Node#57developit merged 2 commits intodevelopit:masterfrom
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
@googlebot I signed it! |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
|
Hi there - this doesn't make redaxios work in Node, it just makes it not error out. You should be using Axios in Node, and only installing the Redaxios alias for browser compilation. In Next you can do this by checking |
|
@developit Sorry, I'll correct myself: I think this will greatly simplify the use of redaxios with Next.js |
|
Ah! Yes I actually helped with the fetch polyfill, I should have thought of that! |
|
So, what you think, @developit? This line of code, where i had added check for |
|
Hey, sorry for dropping the ball on this. I'm okay with the change, just wanted to check on some size tweaks. Hopefully this week! |
Hi!
I'm currently using redaxios in a project with Next.js and found this problem: using redaxios in Node.js leads to ReferenceError because there is no document object in Node.
Axios for this case provides noop functions for non-browser environments: https://github.com/axios/axios/blob/04d45f20911a02e9457db9e9d104aa156e170b11/lib/helpers/cookies.js#L45.
I added a check on the document object so that code with redaxios can be used in the Node.js environment too
@developit, can you review, please?