title: how to use req.body as a function argument - NEXT.js api
body: <p>i want to pass a HTTP POST request body as a function argument.
  here's my code</p>
  <pre><code>export default async function handler(req, res) {
    if (req.method !== &quot;POST&quot;) {
      res.status(405).send({ message: &quot;GET not allowed&quot; });
      return;
    }
    const data = req.body;
  
    try {
      const { hash, uri } = await upload(data); // use req.body {key:value} as func arg
      res.status(200).json({ id: hash, uri: uri });
    } catch (err) {
      res
        .status(500)
        .json({ msg: &quot;upload failed&quot;, error: err.message });
    }
  }
  </code></pre>
  <p>i get an error, <code>error: &quot;Unexpected input: cannot convert \&quot;object\&quot; into ImportCandidate&quot;</code></p>
  <p>this works for a normal &quot;string&quot;</p>