title: How To make a post request from react to node/express api
body: <p>All i need to do is to send my state of invoice details to database through post request but im having troubles doing it is this the right way to do it or am i missing something
  post function works fine if the query is only a string so the only problem is reading the body params</p>
  <pre><code>const postInvoices = () =&gt; {
      const URL = &quot;http://localhost:8000/api/InvSave&quot;;
      axios
        .post(URL,InvDet)
        .then((response) =&gt; {
          console.log(&quot;DATA : &quot;,response);
        })
        .catch((error) =&gt; {
          console.log(error);
        });  
    };
  </code></pre>
  <p>im sending the state on click</p>
  <p>in my api i wrote :</p>
  <pre><code>router.route('/InvSave').post((request,response)=&gt;{
  try{
     const invoices =  request.body
  
     dboperations.PostInvoices(invoices).then(result =&gt; {
        response.status(201).json(&quot;api results :&quot;,result);
     })
  }catch(err){
     console.error(err)
  }
  })
  </code></pre>
  <pre><code>const PostInvoices = async (invoices) =&gt; {
    try {
      let pool = await sql.connect(configInsert);
      console.log(&quot;invoices code&quot;,CODE_ART)
      const q =
        &quot;insert into Packingdetails values('1','&quot;+
        invoices.CODE_ART +
        &quot;','&quot; +
        invoices.a_code +
        &quot;','&quot; +
        invoices.DESC_ART +
        &quot;','&quot; +
          invoices.TotalPc +
        &quot;','&quot; +
          invoices.date+    
        &quot;')&quot;;
        console.log(&quot;query : &quot;+q)
      let invs = await pool.query(q);
      console.log(&quot;saved&quot;);
      return invs.recordsets;
    } catch (err) {
      console.log(&quot;POSTINV : &quot;, err.message);
    }
  };
  </code></pre>