Working with APIs: Clarify default 'cors' mode behavior in CORS section
Because
I wanted to mention the default behavior when sending cross-origin requests using fetch.
This PR
- Mentions that, in case the request being sent is cross-origin,
mode: 'cors'` is set by default. - Adds that explicitly specifying
mode: 'cors'in the options is good for clarity.
Issue
Closes #XXXXX
Additional Information
N/A
Pull Request Requirements
- [x] I have thoroughly read and understand The Odin Project curriculum contributing guide
- [x] The title of this PR follows the
location of change: brief description of changeformat, e.g.Intro to HTML and CSS lesson: Fix link text - [x] The
Becausesection summarizes the reason for this PR - [x] The
This PRsection has a bullet point list describing the changes in this PR - [ ] If this PR addresses an open issue, it is linked in the
Issuesection - [ ] If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
- [ ] If any lesson files are included in this PR, they follow the Layout Style Guide
We can actually probably just remove the { mode: 'cors' } bits entirely (from this lesson and a few other lessons in the curriculum) as that's the default mode for fetch. So the CORS section introducing that to "solve a problem" is redundant because there is no problem when omitted.
If you can put this on hold for a bit, I'm discussing with the team regarding some other CORS material because there might be an additional thing we need to do on top of removing the mode options references. I'll get back to you once we've discussed that through.
That makes sense. I'll put this on hold for now and wait for your update after the team discussion.
@MaoShizhong There was an Issue + PR I opened regarding this in the past. Maybe it is worth looking into why it was closed and not merged Check #23232
@wise-king-sullyman Did you ever get round to confirming this in Safari on MacOS? And discussing how CORS can be introduced in the Rails pathway?
My apologies, this slipped through the cracks on me. I just tested in Safari and confirmed that fetch is defaulting to cors mode so I think we should be ok to remove it as @mao-sz suggested.
Would you still be interested in making this change @Maddily? I know it has been quite a while since you opened this PR.
@wise-king-sullyman Absolutely. I'm on it.
@mao-sz I've removed the cors references from this lesson as well as Fetching Data In React and Async and Await. Could you confirm if these were all the lessons that mentioned mode: 'cors', or if I missed any?