Skip to content

Commit

Permalink
chore: changes in api.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Franqsanz committed Jun 14, 2024
1 parent 2e53b3b commit 9a37fa2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ async function getBooksPaginate(page: number | undefined) {
}

async function getBook(pathUrl: string | undefined) {
return await fetchData(`${API_URL}/book/path/${pathUrl}`);
return await fetchData(`${API_URL}/books/path/${pathUrl}`);
}

async function postBook(books: any) {
return await fetchData(`${API_URL}/book/post`, {
return await fetchData(`${API_URL}/books`, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(books),
Expand Down Expand Up @@ -53,15 +53,15 @@ async function getAllFilterOptions() {
}

async function updateBook(id: string | undefined, books: any) {
return await fetchData(`${API_URL}/book/update/${id}`, {
return await fetchData(`${API_URL}/books/${id}`, {
method: 'PATCH',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(books),
});
}

async function deleteBook(id: string | undefined) {
return await fetchData(`${API_URL}/book/delete/${id}`, {
return await fetchData(`${API_URL}/books/${id}`, {
method: 'DELETE',
});
}
Expand All @@ -71,7 +71,6 @@ async function deleteBook(id: string | undefined) {
async function postRegister(token: string, body: any) {
return await fetchData(`${API_URL}/auth/register`, {
method: 'POST',
// credentials: 'include',
headers: {
Authorization: `Bearer ${token}`,
'content-type': 'application/json',
Expand All @@ -91,9 +90,10 @@ async function getUserAndBooks(
page: number | undefined,
) {
return await fetchData(
`${API_URL}/users/${username}/my-books/${userId}?limit=10&page=${page}`,
`${API_URL}/users/${userId}/${username}/my-books?limit=10&page=${page}`,
{
method: 'GET',
credentials: 'include',
headers: {
Authorization: `Bearer ${token}`,
},
Expand All @@ -102,7 +102,7 @@ async function getUserAndBooks(
}

async function deleteAccount(id: string | undefined) {
return await fetchData(`${API_URL}/users/delete-account/${id}`, {
return await fetchData(`${API_URL}/users/${id}`, {
method: 'DELETE',
});
}
Expand Down

0 comments on commit 9a37fa2

Please sign in to comment.