feat: remove methods from passed objects#569
feat: remove methods from passed objects#569a2937 wants to merge 2 commits intofreeCodeCamp:mainfrom
Conversation
|
Hi @a2937 thanks for tackling this, I hadn't even realised there was an issue 😮💨 Here's what I think we should do: encode the body exactly how fetch does, set the headers accordingly and post them. E.g. the body Does that sound reasonable? |
|
So is this where we're going to be implementing the changes? |
|
@ojeytonwilliams Hold on. This looks like it has the potential to fix this issue too. https://forum.freecodecamp.org/t/advanced-node-and-express-set-up-a-template-engine/780953 |
|
Can we merge this one in then update the body thing in a new PR? |
Yes, that's right, I don't awaitable-post should default to modifying the message. At least not preemptively. Just stringifying by default could cause something else to break and we wouldn't know because we don't test the lessons that interact with a server. For example, fetch can handle circular objects (it just sends There's a couple of improvements we can make. One is to implement error handling in awaitable-post (I've been looking into that, so I'd be happy to polish that off and create a PR). The other is to avoid the errors in the first place. |
|
Actually, the more I think about it, the less I like the idea of handling DataCloneError. Without re-implementing Given that, we should focus on avoiding generating the errors. Let me know what you think. |
|
What kind of tests can I write to make sure |
|
Good question. To test it, I think it's enough to unit test the function that makes the options both cloneable and ensures they have the right headers. For the first part, they should check that the output of function can be |
Checklist:
Update index.md)Related to freeCodeCamp/freeCodeCamp#66132
While it realistically will not that fix the issue; seeing as how a JSON stringified version of
URLSearchParamswill return an empty object, this could be pretty neat behavior for other objects being passed around in the future and help them be cloned.