Skip to content

Commit

Permalink
refactor: import da url e remoção das functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavogularte committed Jul 18, 2024
1 parent 2f69067 commit 68c3e65
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 40 deletions.
40 changes: 0 additions & 40 deletions src/services/login/loginService.js

This file was deleted.

29 changes: 29 additions & 0 deletions src/services/loginService.js
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,
};
}
},
};

0 comments on commit 68c3e65

Please sign in to comment.