Giter Site home page Giter Site logo

node-crash-course's Issues

mongoose promise while connneciting.

mongoose.connect(url)
.then(....)
This gives syntax error.
but I tried using callback in mongoose.connect like..
mongoose.connect(url,(err,db)=>{
if (err){console.log(err)}
else {console.log('success')} //this worked
}

reference error

I have tried to run your code but i keep getting an error saying blog is not defined error and it is showing me the error is in line ejs file of index.ejs line 10. i cant find any solutions for this error

Error when running npm install -g nodemon

I had an error when I tried to run npm install -g nodemon
I had a running script disabled error from the terminal and this is how I fixed it:

  1. Open the Run command box with Windows key + R
  2. Type powershell in the dialogue box
  3. Click Ctrl + Shift + Enter key to open powershell
  4. Paste the command : Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
  5. Press Y on prompt and hit enter
  6. Go back to your text editor(I use VSCode) and run the command npm install -g nodemon and run your server

Missing files

i can not find the files, have they been removed?

blog_details controller

Hi Net Ninja,

I followed your tutorial on youtube (thanks again for the great tutorial ), and I had to adapt the blog_details controller at two points for not running into errors (see (1) and (2) in the code snippet below):

const blog_details = (req, res) => {

    //(1) id contains a space as first character, I don't know why, I have to remove it
    const id = req.params.id.slice(1)

    Blog.findById(id).then(result => {

        //(2) if blog is not found result = null, I have to check for that for preventing error at this point,
        // otherwise the webpage hangs
        // you can trigger this behaviour by using a valid blog id and then change e.g. the last digit
        if(result != null)
            res.render('./blogs/details', { blog: result, title: 'Blog Details' })
        else
            res.status(404).render('404', {title: 'Blog not found' })

    }).catch( err => {
        console.log(err)
        // you can trigger this behavior e.g. with /blogs/isajfjklsfnhhsafkhnbsdf
        res.status(404).render('404', {title: 'Site not found' })
    })
}

I am using:
wsl2 Ubuntu 20.04.2 LTS
node v14.17.2
[email protected]

Nodemon

Nodemon is updating and auto refreshing only the server and those changes are not changed in the browser. so that we have to restart the server everytime. i don't know how your browser is updating the changes automatically.

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.