-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TODO for setting up openapi-fetch #214
Conversation
frontend/src/hooks/api.tsx
Outdated
const authMiddleware: Middleware = { | ||
async onRequest({ request }) { | ||
const accessToken = localStorage.getItem("AUTH"); | ||
if (!accessToken) { | ||
throw new Error("No access token found"); | ||
} | ||
|
||
request.headers.set("Authorization", `Bearer ${accessToken}`); | ||
return request; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah interesting, i didn't realize this code path still existed, seems like we should merge with auth.tsx
frontend/src/hooks/ApiCalls.tsx
Outdated
fd.append("file", file); | ||
fd.append("metadata", JSON.stringify(request)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
// console.error("Error uploading file:", error); | ||
// } | ||
const { error } = await APICalls.upload(selectedFile, { | ||
artifact_type: "image", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be urdf here?
// }); | ||
const { response, error } = await APICalls.upload(compressedFile, { | ||
artifact_type: "image", | ||
listing_id: "5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should add listing_id
to props i believe? like the component should be used to upload an image for an associated listing
frontend/src/hooks/auth.tsx
Outdated
const authMiddleware: Middleware = { | ||
async onRequest({ request }) { | ||
const accessToken = localStorage.getItem("AUTH"); | ||
if (!accessToken) { | ||
throw new Error("No access token found"); | ||
} | ||
|
||
request.headers.set("Authorization", `Bearer ${accessToken}`); | ||
return request; | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is duplicated below
frontend/src/hooks/auth.tsx
Outdated
if (!accessToken) { | ||
throw new Error("No access token found"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is incorrect, no? what if the user is not logged in - they should still be able to make api calls to the public endpoint?
This fixes @codekansas comments TODO.
however listing_id is hardcoded. I am not sure if we are going to use ImageUpload /UDRFUpload components.