-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: import da url e remoção das functions
- Loading branch information
1 parent
2f69067
commit 68c3e65
Showing
2 changed files
with
29 additions
and
40 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { url } from './api'; | ||
|
||
export const LoginService = { | ||
login: async (email, password) => { | ||
try { | ||
const response = await fetch(`${url}/login`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ email, password }), | ||
}); | ||
|
||
if (!response.ok) throw new Error('Erro ao fazer o login'); | ||
|
||
const data = await response.json(); | ||
return { | ||
success: true, | ||
token: data.token, | ||
}; | ||
} catch (error) { | ||
console.error(`An error occurred: ${error}`); | ||
return { | ||
success: false, | ||
message: error.message, | ||
}; | ||
} | ||
}, | ||
}; |