Skip to content

Commit

Permalink
feat: #6 update frontend api requests to ensure json format
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianrbp committed Aug 9, 2024
1 parent 7b54b7b commit d8bc363
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
- Seleccionar: Reopen in container
- Seleccionar: "Vue Container"
- Dentro ejecutar mocked: `yarn dev`
- Dentro ejecutar api: `yarn serve:api`
- (alternativa) Dentro ejecutar api: `yarn serve:api`
- navegar a 0.0.0.0:8080 para empezar a usar la app
- Ejecutar tests e2e:
```bash
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/api/AvailabilityApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ export const requestAvailabilities = async (
} else {
try {
const response = await fetch(
`/api/company_services/${serviceId}//engineers/availability?week=${weekId}`
`/api/company_services/${serviceId}//engineers/availability?week=${weekId}`,
{
headers: {
Accept: "application/json",
},
}
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
Expand Down Expand Up @@ -49,6 +54,7 @@ export const storeAvailabilities = async (
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(availabilityPayload),
}
Expand Down
27 changes: 23 additions & 4 deletions frontend/src/api/CompanyServiceApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export const fetchCompanyServices = async (): Promise<CompanyService[]> => {
});
} else {
try {
const response = await fetch("/api/company_services");
// const response = await fetch("/api/company_services");
const response = await fetch("/api/company_services", {
headers: {
Accept: "application/json",
},
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
Expand All @@ -45,7 +50,11 @@ export const requestWeeks = async (serviceId: number): Promise<Weeks> => {
});
} else {
try {
const response = await fetch(`/api/company_services/${serviceId}/weeks`);
const response = await fetch(`/api/company_services/${serviceId}/weeks`, {
headers: {
Accept: "application/json",
},
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
Expand Down Expand Up @@ -76,7 +85,12 @@ export const requestShifts = async (
} else {
try {
const response = await fetch(
`/api/company_services/${serviceId}/shifts?week=${weekId}`
`/api/company_services/${serviceId}/shifts?week=${weekId}`,
{
headers: {
Accept: "application/json",
},
}
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
Expand Down Expand Up @@ -108,7 +122,12 @@ export const requestEngineers = async (
} else {
try {
const response = await fetch(
`/api/company_services/${serviceId}/engineers?week=${weekId}`
`/api/company_services/${serviceId}/engineers?week=${weekId}`,
{
headers: {
Accept: "application/json",
},
}
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
Expand Down

0 comments on commit d8bc363

Please sign in to comment.