Giter VIP home page Giter VIP logo

part3-notes-backend's People

Contributors

kkiilas avatar lliangthomas avatar mluukkai avatar sergioruizsan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

part3-notes-backend's Issues

[Bug] - Getting Error while get a note

Description of the problem

  • Error - Terminal throw an error : “ Cannot set headers after they are sent to the client ” when i use GET method to get a note
  • Solution - delete response.json(note)
  • Screenshot of the error
  1. Postman
  2. Terminal
// Error Code
app.get('/api/notes/:id', (request, response) => {
  const id = Number(request.params.id)
  const note = notes.find(note => note.id === id)

  if (note) {
    response.json(note)
  } else {
    response.status(404).end()
  }
// delete this line
  response.json(note)
})

// Solution 
app.get('/api/notes/:id', (request, response) => {
  const id = Number(request.params.id)
  const note = notes.find(note => note.id === id)

  if (note) {
    response.json(note)
  } 

  if(!note){
    response.status(404).end()
  }
})

Reproduction Repo:

null

Node Version:

v16.19.1

Platform and Version:

win 11 22H2


Other

Good morning, teacher
I am a JavaScript learner from China,thanks for your open source projects and translate it in chinese,I gain a lot. that why I yearn for your university. however, I didn't study hard in college,my GPA is low now, so I can't apply to your university. this is my first official writing issue,if there are any problems, please point them out and provide information in the correct format, I will modify it next time. If you come to Hang Zhou(Zhe Jiang) to play,I will welcome you warmly.
Yours
China student
2023.5.10

about close close db connection

Is it better to put the close database operation in Promise finally?

Person
.find({})
.then(persons=> {
// ...
mongoose.connection.close()
})

Script build:ui - All branches

Vite build in a directory named "dist"

Need to change the build:ui script in all branches from :
"build:ui": "rm -rf build && cd ../frontend/ && npm run build && cp -r build ../backend"
into :
"build:ui": "rm -rf dist && cd ../frontend/ && npm run build && cp -r dist ../backend",

Can't see db.json content

I can't see db.json content using a new path in the baseUrl variable, the last path was '/notes', then we need to change it to '/api/notes', but with this url path I can't see the content.

I already visited the '/api/notes' url and only shows and empty object.
If I visit the last url '/notes' I can see them...

How to solve this problem?

Create a README file.

Please create a ReadMe file with short texts about the project and each branches.
Some basic commands regarding git and npm.

I would like to add one if assigned.

confusing

this part from part4, User administration, Creating a new note made me really confused. I ended up just skipping it.:

The note scheme will also need to change as follows in our models/note.js file:

const noteSchema = new mongoose.Schema({
  content: {
    type: String,
    minLength: 5,
    required: true,
  },
  important: Boolean,
  user: String,})

Maybe I didnt understand something important or maybe this is worth looking over why this part is here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.