Show error modal
This commit is contained in:
+10
-4
@@ -15,16 +15,22 @@ export default async function register(email, password, name, lastname, phone) {
|
||||
body: JSON.stringify({ email, password, name, lastname, phone }),
|
||||
});
|
||||
|
||||
console.log('Code HTTP :', response.status);
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
if (response.status === 422) {
|
||||
return {
|
||||
status: 422,
|
||||
errors: data.errors
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error(`Erreur HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
return { status: response.status, data };
|
||||
|
||||
} catch (error) {
|
||||
return error;
|
||||
return { status: "error", error };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user