My endpoints aren't working, and most likely because the server on which express is isn't running correctly. I run my files with npm run dev
and my express files are in /middleware
. The endpoint which I'm trying to fetch data from is in a route in /middleware/routes/crash.js
. In my vue file I have axios preforming a get request to localhost:3000/api/crash/:id
, however axios returns a 400 error indicating that the file hasn't been found running on the server.
package.json:
"scripts": {
"dev": "nuxt"
}
/middleware/index.js:
const express = require('express')
const app = express()
const crash = require('./routes/crash')
app.use(crash)
module.exports = {
path: '/middleware',
handler: app
}
/middleware/routes/crash.js:
const { Router } = require('express')
const router = Router()
const crypto = require("crypto");
...
router.get('/api/crash/:id')