Jak mogę skonfigurować dane swojego routera, aby oni pokazywali mi wszystkie identyfikatory?

0

Pytanie

W tym routerze udało mu się pokazać tylko pewien identyfikator, ale w ramach tego identyfikatora chciałbym pokazać inne, które mam w mojej bazie danych.

router.get('/detalles/:id', (req, res) => {
    const id = req.params.id;
    conexion.query('SELECT * FROM noticias WHERE id=?', [id], (error, results) => {
        if (error) {
            throw error;
        } else {
            res.render('detalles', { noticias: results[0], results: results });
        
        }
    });
});

Na górze są mi potrzebne tylko dane określonego identyfikatora, poniżej chcę pokazać inne.

mysql node.js router
2021-11-22 18:58:29
1

Najlepsza odpowiedź

-1

Polecam ci przejść trasę "Zobacz wszystkie", co oznacza, że będziesz używać identyfikatorów. On myśli, że to będzie wyglądać tak. ! Uwaga ! Nie zapomnij, aby umieścić go przed trasą "/detalles/:id", aby uniknąć konfliktu między nimi, aby nie wywoływał /detalles/:id bez żadnego identyfikatora.

router.get('/detalles/', (req, res) => {
    conexion.query('SELECT * FROM noticias', (error, results) => {
        if (error) {
            throw error;
        } else {
            res.render('detalles', { noticias: results, results: results });
        }
    });
});

2021-11-22 23:18:53

W innych językach

Ta strona jest w innych językach

Русский
..................................................................................................................
Italiano
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................