Untitled
unknown
javascript
9 months ago
826 B
13
Indexable
async function createUserAccount(apiKey, email) {
try {
// Build URL with query parameters
const url = `/CreateAccount?ApiKey=${encodeURIComponent(apiKey)}&Email=${encodeURIComponent(email)}`;
// Make the POST request
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
});
// Check if the request was successful
if (!response.ok) {
throw new Error(`Failed to create account: ${response.status} ${response.statusText}`);
}
// Parse and return the JSON response
return await response.json();
} catch (error) {
console.error('Error creating user account:', error);
throw error;
}
}Editor is loading...
Leave a Comment