You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Localhost:5000/gigs页面无法加载问题求助

Express + Sequelize /gigs 页面卡顿加载无响应问题

问题描述

严格按照教程操作后,访问localhost:5000/gigs页面时一直卡顿无法加载,页面无任何报错信息,但终端显示数据库查询操作已成功执行。将路由处理逻辑替换为res.send('Hello')后,页面可正常加载,因此怀疑问题出在findAll()函数调用环节。

相关代码

const express = require('express');
const router = express.Router();
const db = require('../config/database');
const Gig = require("../models/Gig");

router.get('/', (req,res) => 
    Gig.findAll()
        .then(gigs => {
            console.log(gigs);
            res.sendStatus(200);
        })
        .catch(err => console.log(err)));

//res.send("Hello there")
module.exports = router;

问题原因与解决

已定位问题:Sequelize.js会自动为数据表名称添加后缀s,终端中显示的"查询成功"实际上是针对错误的表名执行的操作,导致findAll()并未获取到预期数据,进而引发页面加载异常。代码本身不存在问题,只需确保数据库中的表名与Sequelize模型映射的表名一致(或通过模型配置指定正确的表名)即可解决。

内容的提问来源于stack exchange,提问作者Aditya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 13:06:23