In the following Node JS code:
import express from "express";
import pg from "pg";
import cors from "cors";
import bodyParser from "body-parser";
import { PORT, DB_USER, DB_HOST, DB_NAME, DB_PASS, DB_PORT } from "./config.js";
const { Pool } = pg;
const app = express();
app.use(express.json());
app.use(cors());
app.use(bodyParser.json());
const pool = new Pool({
user: DB_USER,
host: DB_HOST,
database: DB_NAME,
password: DB_PASS,
port: DB_PORT,
});
app.get("/", async (req, res) => {
const result = await pool.query(`SELECT * FROM usuarios;`);
const rows = result.rows;
res.json(rows);
});
app.post("/sigfox", (req, res) => {
res.json(req.body);
res.sendStatus(200);
});
app.listen(PORT, () => {
console.log(`Servidor iniciado en http://localhost:`, PORT);
});
I am trying to send the temperature of my "SigFox DEVKIT" by POST method to the server, but when I enter the server I get the error "Cannot GET /sigfox".
But in the Sigfox Backend CallBack he tells me that he sent the data correctly.
[SigFox] CallBacks Results --> https://i.stack.imgur.com/tFJqv.png
I don't know why this happened. I show you my Callback Settings in case I have something wrong.
[SigFox] CallBack Settings --> https://i.stack.imgur.com/92DGL.png
Why did that happen and how can I solve it?
Previously I thought it was because I was working with a local server, but now with a hosted server I get the same error. Please, I need help.