X-press publishing project: test not returning 200 status code

Thanks to previous threads I figured out how to get the project started by rolling back to an older version of node.
Despite checking my code against the video I can’t get it to pass the first round of testing for the GET route for ‘/api/artist’.

Any suggestions for where I’m going wrong?

This is the code for artists.js that should return the 200 status code and return currently employed artists.

const express = require('express');
const artistsRouter = express.Router();
const sqlite3 = require('sqlite3');
const db = new sqlite3.Database(process.env.TEST_DATABASE || './database.sqlite');

artistsRouter.get('/', (req, res, next) => {
    db.all('SELECT * FROM Artist WHERE Artist.is_currently_employed = 1', (err, artists) => {
        if (err) {
            next(err);
          } else {
            res.json({artists: artists});            
          }
    });

});

This is the test output

  GET /api/artists
GET /api/artists 404 2.659 ms - 150
    13) should return all currently-employed artists
GET /api/artists 404 0.337 ms - 150
    14) should return a status code of 200

Thanks.

1 Like

I’m having the same problem. I can’t get my first test to pass, returning the same out put.
Thank you

Same problem over here. Have anyone find the solution yet?

Hey there! I was having the same issue but I ran both “node seed.js” and “node migration.js” (in that order) and I managed to get past it. What I don’t understand is why didn’t the Table get cleared out and the seed (which inserted two rows into the table) persisted on the table. I have no idea why but that solved it!