-
-
Save ni8mr/2d8654e1e102f27abf83ab38c4125b10 to your computer and use it in GitHub Desktop.
Using spread syntax to conditionally add JSON key, value to object. Fetch example using POST and Authorization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const POST = (auth) => ({ | |
| method: "POST", // *GET, POST, PUT, DELETE, etc. | |
| mode: "cors", // no-cors, cors, *same-origin | |
| headers: { | |
| "Content-Type": "application/json", | |
| ...(auth ? { "Authorization": auth } : {}) | |
| }, | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment