I develop with mates for school a nodejs website. But I have this problem when I npm start. I have been looking for few times a solution but find anything working for us.
Here is the error we get:
read: [Function],
secret: undefined,
cookies: { 'jenkins-timestamper-offset': '-7200000' },
signedCookies: {},
route:
{ path: '/question',
stack: [ [Object], [Object], [Object] ],
methods: { post: true, put: true, delete: true } } }
connect ECONNREFUSED
I just pick the last few lines because there are too many to copy/paste.
Here is my index.js file:
var express = require('express');
var mysql = require("mysql");
var md5 = require('MD5');
var router = express.Router();
var app=express();
var bodyParser = require("body-parser");
var questionList = [];
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
router.get("/ListQuestion",function (req,res){
client.query('SELECT * from question',function (err,results) {
res.render('ListQuestion', {listeQuestion: results});
})
});
/* GET home page. */
router.get('/', function(req, res) {
res.status(200).render('index', { title: 'Web-Service' });
});
router.get('/answer/:URI', function(req, res) {
var client=mysql.createConnection({
host : '172.17.0.2',
user : 'root',
password : 'rootroot',
database : 'questionreponse'
});
client.query('SELECT * from question WHERE answer !="NULL" AND uri= "'+req.params.URI+'" GROUP BY answer ORDER BY answer DESC' , function (error, results) {
console.log(results);
if (results && results[0] && results[0].answer && results[0].answer!=''){
res.status(200).render('answer', {answer: results[0].answer});
console.log(results[0].answer);
}else{
Same as before I cant copy the whole file because too long, if you need specific lines you can ask for.
If you have any solution to make it work I will take it.
Thanks in advance. :)
via Raydowne
No comments:
Post a Comment