I need to set value for my variable in API request and then use it in function outside request.
import React from 'react'
export default async (req, res) => {
  if (req.method === 'GET') {
    try {
      const imageToBase64 = require('image-to-base64')
      
      const [a,setA] = React.useState('')
      imageToBase64('url') // Path to the image
      .then(
          (response) => {
             setA(response)
          }
      )
      .catch(
          (error) => {
              console.log(error); // Logs an error if there was one
          }
      )
           console.log('a')
    } catch (error) {
      console.error(error)
    }
  }
}
The problem is that file I editing just use export default, it's not wrapped in class which extends React.Component and dont' use render function. How can I assigned response value to my variable?
