I have nodeJs back end where i have created this api
app.post("/addInvoice", (req, res) => {
let invoice = req.body;
var sql =
"INSERT INTO invoice (address, email, billnumber, price, status) VALUES(?, ?, ?, ?, 'sent');";
mysqlConnection.query(
sql,
[
invoice.address,
invoice.customeremail,
invoice.billnumber,
invoice.totalprice,
],
(err, rows, fields) => {
if (!err) {
res.send(rows);
} else {
res.send(err);
}
}
);
});
when I call this API using post man it works perfectly.
but now i need to call it on buttonclick from my react-native app.
axios
.post("http://localhost:3000/addInvoice", {
address: address,
customeremail: email,
billnumber: invoicenumber,
totalprice: totalPrice,
})
.then((response) => {
alert(response);
});
I nothing happens when I send this and the alert(responce) returns nothing.
what could be the problem?