Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

APIs

A R
A R
12,834 Points

Sequelize/Tables Problem

I'm having a problem with some linked SQL tables, and trying to retrieve data from them with Sequelize. When I'm on DB Browser for SQLite, the tables all exist. But when I try to findAll() or findByPK() my table 'Courses' I'm getting a "SequelizeDatabaseError" with the message: "SQLITE_ERROR: no such table: Courses"

I'll link the repository here: https://github.com/AeronRoemer/rest-api-project

And this is the code from the 'routes' page where the GET request is coming from

const express = require('express');
const router = express.Router();
const Users = require('../models').Users;
const Courses = require('../models').Course;
module.exports = router;

/* Handler function to wrap each route. */
function asyncHandler(cb){
    return async(req, res, next) => {
      try {
        await cb(req, res, next)
        res.status(201)
      } catch(error){
        res.status(500).send(error);
      }
    }
  }

  //send a GET request to view all quotes
router.get('/courses', asyncHandler(async (req, res) =>{
    let allCourses
    //console.log(Courses)
    try {
        allCourses = await Courses.findAll();
        res.json(courses) //converts to JSON object
      } catch (error) {
          res.json({error: error,
        message: error.message})
      }
}))