Created
February 8, 2026 13:58
-
-
Save vanaf1979/a7b2f3b65993b1724df5bf704064d1d7 to your computer and use it in GitHub Desktop.
Fetch post
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
| const createNewUser = async (userData) => { | |
| try { | |
| const response = await fetch('https://api.since1979.dev/users', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Accept': 'application/json' | |
| }, | |
| body: JSON.stringify(userData) | |
| }); | |
| if (!response.ok) { | |
| throw new Error('Failed to create user'); | |
| } | |
| const result = await response.json(); | |
| console.log('Success:', result); | |
| } catch (error) { | |
| console.error('Error:', error); | |
| } | |
| }; | |
| createNewUser({ name: "Stephan", role: "Developer" }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment