Skip to content

Instantly share code, notes, and snippets.

@vanaf1979
Created February 8, 2026 13:58
Show Gist options
  • Select an option

  • Save vanaf1979/a7b2f3b65993b1724df5bf704064d1d7 to your computer and use it in GitHub Desktop.

Select an option

Save vanaf1979/a7b2f3b65993b1724df5bf704064d1d7 to your computer and use it in GitHub Desktop.
Fetch post
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