get url after uploading in client side

so i have this form and my logic right here is to upload the file, then to get the url, so i can make a POST request to the server side and otherwise to mongoDB, but the thing is when i upload the image to from my client side, how can i make the way that i get my url in client side, so i can make an api request?. Yes im a noob.
No description
Solution:
🫡
Jump to solution
4 Replies
notash
notashOP•4mo ago
someone please help me
Neto
Neto•4mo ago
.onUploadComplete(async ({ metadata, file }) => {
console.log("file url", file.url);

// !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback
return { url: file.url };
})

<UploadButton
endpoint="imageUploader"
onClientUploadComplete={(res) => {
// Do something with the response
console.log("Files: ", res);
alert("Upload Completed");
}}
onUploadError={(error: Error) => {
// Do something with the error.
alert(`ERROR! ${error.message}`);
}}
/>
.onUploadComplete(async ({ metadata, file }) => {
console.log("file url", file.url);

// !!! Whatever is returned here is sent to the clientside `onClientUploadComplete` callback
return { url: file.url };
})

<UploadButton
endpoint="imageUploader"
onClientUploadComplete={(res) => {
// Do something with the response
console.log("Files: ", res);
alert("Upload Completed");
}}
onUploadError={(error: Error) => {
// Do something with the error.
alert(`ERROR! ${error.message}`);
}}
/>
notash
notashOP•4mo ago
THANK YOU MAN YOU'RE A LIFE SAVERR
Solution
Neto
Neto•4mo ago
🫡
Want results from more Discord servers?
Add your server