Refactor register service to enhance error handling
Modified the doRegister function within register.service.ts to provide better error handling. Responses now return an object format, and an error catch block has been added. Additionally, minor changes were made to the workspace.xml.
This commit is contained in:
parent
8f8accebeb
commit
e3a5c0a44a
21
.idea/workspace.xml
generated
21
.idea/workspace.xml
generated
@ -5,12 +5,8 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="42d2b9e8-8d19-46be-8636-69ddba4519e4" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/src/services/register.service.ts" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pnpm-lock.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/pnpm-lock.yaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/components/register-form.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/register-form.tsx" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/services/register.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/services/register.service.ts" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -88,7 +84,7 @@
|
||||
<workItem from="1715776267209" duration="3260000" />
|
||||
<workItem from="1715781823049" duration="3317000" />
|
||||
<workItem from="1715794057604" duration="8757000" />
|
||||
<workItem from="1716275453494" duration="15634000" />
|
||||
<workItem from="1716275453494" duration="15864000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Remove toast components and added register form The toast related components (toast.tsx, toaster.tsx, use-toast.ts) were removed from the code base. On the other hand, the register-form.tsx file was updated with a form for users to create an account. A new file toast-box.tsx was also added to display a custom message box.">
|
||||
<option name="closed" value="true" />
|
||||
@ -106,7 +102,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1716287283999</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="3" />
|
||||
<task id="LOCAL-00003" summary="Integrate registration service and axios dependency The registration form now makes use of a new registration service. Axios, a necessary dependency for making HTTP requests in this service, has been added to the project. Additionally, logging has been improved in the user registration process to provide better debugging information.">
|
||||
<option name="closed" value="true" />
|
||||
<created>1716300616157</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1716300616160</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="4" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -115,6 +119,7 @@
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Remove toast components and added register form The toast related components (toast.tsx, toaster.tsx, use-toast.ts) were removed from the code base. On the other hand, the register-form.tsx file was updated with a form for users to create an account. A new file toast-box.tsx was also added to display a custom message box." />
|
||||
<MESSAGE value="Add ProfilePage, update RegisterForm and ToastBox components Added new ProfilePage component with necessary UI layout and buttons. Updated RegisterForm component with form validation using Zod schema and improved error handling. Updated icons in ToastBox component for proper display. Added necessary dependencies for form handling and validation." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Add ProfilePage, update RegisterForm and ToastBox components Added new ProfilePage component with necessary UI layout and buttons. Updated RegisterForm component with form validation using Zod schema and improved error handling. Updated icons in ToastBox component for proper display. Added necessary dependencies for form handling and validation." />
|
||||
<MESSAGE value="Integrate registration service and axios dependency The registration form now makes use of a new registration service. Axios, a necessary dependency for making HTTP requests in this service, has been added to the project. Additionally, logging has been improved in the user registration process to provide better debugging information." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Integrate registration service and axios dependency The registration form now makes use of a new registration service. Axios, a necessary dependency for making HTTP requests in this service, has been added to the project. Additionally, logging has been improved in the user registration process to provide better debugging information." />
|
||||
</component>
|
||||
</project>
|
@ -4,11 +4,19 @@ import axios from "axios";
|
||||
|
||||
|
||||
async function doRegister(data: object) {
|
||||
return await axios.post('http://localhost:3333/auth/register', data)
|
||||
return axios.post('http://localhost:3333/auth/register', data)
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
return response
|
||||
return {
|
||||
status: response.status,
|
||||
data: response.data
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.warn(error);
|
||||
return {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default doRegister;
|
Loading…
x
Reference in New Issue
Block a user