Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
Restful NodeJs can't load database Mysql

I was build new project with NodeJs. I got this code from youtube channel and its been uploaded 2 years ago. when I trying to practice I got some error. my database cant load and always show "No Comic Here".

this my index.js code:

```    /*
    
    
    
    */
    
    var express = require('express');
    var mysql = require('mysql');
    
    //
    var connnect=mysql.createConnection
    ({  host:'localhost',
        user:'root',
        password:'',
        database:'testmanga'
    });
    
    //
    var app=express();
    var publicDir=(__dirname+/'public'/);
    app.use(express.static(publicDir));
    
    //
    app.get("/banner",(req,res,next)=>{
        connnect.query('SELECT * FROM banner',function(error,result,fields){
            connnect.on('error',function(err) {
                console.log('[MY SQL ERROR]', err);
            });
    
            if (result && result.lenght)
                {
                    res.end(JSON.stringify(result));
                } 
                else
                {
                    res.end(JSON.stringify("No Comic Here"));
                }
        })
    });
    
    //
    app.get("/comic",(req,res,next)=>{
        connnect.query('SELECT * FROM manga',function(error,result,fields){
            connnect.on('error',function(err) {
                console.log('[MY SQL ERROR]', err);
            });
    
            if (result && result.lenght)
                {
                    res.end(JSON.stringify(result));
                } 
                else
                {
                    res.end(JSON.stringify("No Comic Here"));
                }
        })
    });
    
    //
    app.listen(3000, ()=>{
        console.log("you're connected to port 3000");
    })```

I've been trying for changing localhost to 127.0.0.1, but still no working.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!