[Vuejs]-Can't Access Sqlite db with Postman Even with No Auth Schedule Set Up

0👍

There was 2 things causing this problem. First, instead of query I used get. Second instead of app.route I used app.get. The code that correctly runs the /test api looks like this:

index.js

const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
const { db, port } = require("./config.js");

app.use(bodyParser.json());
app.use(
  bodyParser.urlencoded({
    extended: true,
  })
);
app.use(cors());

const getUsers = (request, response) => {
  console.log("ran /test");
  db.get("SELECT * FROM wallets", (error, results) => {
    if (error) {
      throw error;
    }
    response.status(200).json(results.rows);
  });
};

app.get("/test", getUsers);

app.listen(port);
console.log("App is running on port " + port);

Leave a comment