'if statement not running which includes an async function

I have an async function inside an if/else statement. I just want to check whether there is a file in the request body before even using it otherwise it throws an error. Why is this happening? And is there anything better I could do to handle the problem ?

//save image to cloudinary
if (typeof(banner) !== undefined) {
  //this piece of code is always executing even if the image is not present in request or is undefined
  cloudinary.uploader.upload(banner,
    async function(error, result) {

      if (error) {
        return res.status(409).send("Something went wrong while uploading image")
        console.log(error)
      }
      article.banner = result.url
      const savedArticle = await article.save()
      return res.status(201).send(JSON.stringify({
        redirect_uri: "/articles/" + savedArticle.slug
      }))

    })
} else {
  return res.status(400).send("Missing file")
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source