2

I'm making an API that takes an image from the database by getting it using the URL like this (http://localhost:3000/city/?name=encenadaport&width=200&height=200) I made the code and the function that handle the resizing issue the problem is when I write the URL it gives me Error: ENOENT: no such file or directory, stat 'D:\Programming\Udacity_FWD\Projects\Image_Api\assets\thumbnail\santamonica_300_200.png' and when I rerun it works I think it sends a response before it creates the resized image what shall I do this is the part that handles the resizing

enter code here

  imgResize(imageLoc, name as string, width, height, newLocation);

  res.sendFile(`${newLocation}/${name}_${width}_${height}.png`);

 

1 Answer 1

1

Try making imgResize async function. Then await imgResize before calling res.sendFile. I am guessing that res.sendFile is being called before imgResize finishes processing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.