added test image upload
This commit is contained in:
8
src/utils/fileUpload.js
Normal file
8
src/utils/fileUpload.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export function createFormData(request, file) {
|
||||
const formData = new FormData();
|
||||
Object.entries(request.formData).forEach(([key, value]) => {
|
||||
formData.append(key, value);
|
||||
});
|
||||
formData.append("file", file, file.name);
|
||||
return formData;
|
||||
}
|
||||
@@ -5,6 +5,12 @@ export const client = createTRPCProxyClient({
|
||||
links: [
|
||||
httpBatchLink({
|
||||
url: CONFIG.api_url,
|
||||
headers: () => {
|
||||
let token = localStorage.getItem("token");
|
||||
return {
|
||||
Authorization: token ? `Bearer ${token}` : "",
|
||||
};
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user