Refine - MUI CRUD REST API (Express) and MSSQL
Hi I m pretty noob with Refine and I m trying to adapt the example of the blog-posts and categories admin to my database to have an easy to use and deeply CRUD Admin.
I think I have configured my Express API as requested in the Doc but when I connect to my database I get only the list of my first resource. The table is listed but then all the buttons (edit, delete etc.) do not work and somehow when I hover those buttons the address in the same as the list (I have tried a lot of things but could not figure out)
in the pages: I have created a similar folder for the cities, replace all the blog-posts etc with cities
my cities.js:
const express = require('express');
const router = express.Router();
const { poolPromise, sql } = require('../db');
// POST - Create City (Protected Route)
router.post('/', async (req, res) => {
const { cityName } = req.body;
try {
const pool = await poolPromise;
const result = await pool.request()
.input('cityName', sql.NVarChar, cityName)
.query('INSERT INTO app.Cities (CityName) OUTPUT Inserted.* VALUES (@cityName)');
res.status(201).json(result.recordset[0]);
} catch (err) {
res.status(500).json({ message: "Error adding city", error: err.message });
}
});
etc....
I think I have configured my Express API as requested in the Doc but when I connect to my database I get only the list of my first resource. The table is listed but then all the buttons (edit, delete etc.) do not work and somehow when I hover those buttons the address in the same as the list (I have tried a lot of things but could not figure out)
in the pages: I have created a similar folder for the cities, replace all the blog-posts etc with cities
my cities.js:
const express = require('express');
const router = express.Router();
const { poolPromise, sql } = require('../db');
// POST - Create City (Protected Route)
router.post('/', async (req, res) => {
const { cityName } = req.body;
try {
const pool = await poolPromise;
const result = await pool.request()
.input('cityName', sql.NVarChar, cityName)
.query('INSERT INTO app.Cities (CityName) OUTPUT Inserted.* VALUES (@cityName)');
res.status(201).json(result.recordset[0]);
} catch (err) {
res.status(500).json({ message: "Error adding city", error: err.message });
}
});
etc....
