routing error Cannot Get /api/name student activity

105
February 03, 2022, at 08:30 AM

I am trying to recreate a Note Taking App using Express. My code follows the instructor's example but when I deploy it and try to add a new note I get the error cannot get/api/name...I am not sure what I am doing wrong.

enter code here

const fs = require('fs');
const path = require ('path');
const express = require('express');
const dbJson = require('./db/db.json')
const {v1 : uuidv1} = require('uuid');

const PORT = process.env.PORT || 3001;
const app = express();
app.use(express.urlencoded({extended: true}));
app.use(express.json());
app.use(express.static("public"));
app.get('/notes', (req, res) => {
    res.sendFile(path.join(__dirname, './public/notes.html'));
});
app.get('/api/notes', (req,res) => {
    const dataNotes = fs.readFileSync(path.join(__dirname, './db/db.json'), "utf-8");
    const parseNotes = JSON.parse(dataNotes);
    res.json(parseNotes);
});
Answer 1

Add at the end: app.listen(PORT);

That will work. The problem was that you didn't start the server

Rent Charter Buses Company
READ ALSO
Send Json file for Async Validation

Send Json file for Async Validation

I am working with Angular reactive forms and async validation and instead of a normal value I want to send Json file for validation

134
I'm on windows os, I'm trying to export the data from mysql workbench to my local file system. But showing an error message like (no disk space)

I'm on windows os, I'm trying to export the data from mysql workbench to my local file system. But showing an error message like (no disk space)

I've searched many threads online but none of them worked for meI found solutions for linux but there is no solution related to windows operating system

108
How can I fade images in sequence? [duplicate]

How can I fade images in sequence? [duplicate]

How do I stop the second image from beginning to fade in until the first one has fully faded in?

110