Reputation: 1
hi everyone i have a probleme whene i want to fetch data from couchdb to file .ejs i have this probleme "Server started on 3000 Port undefined"
this is my code
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const NodeCouchdb = require('node-couchdb');
const couch =new NodeCouchdb({
auth:{
user: 'admin' ,
password: 'admin'
}
});
const dbName = "mydata";
const viewUrl = "_design/_allproducts/_view/all";
couch.listDatabases().then(function(dbs){
console.log(dbs);
});
const app = express();
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use (bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.get('/', function(req,res){
couch.get(dbName, viewUrl).then(function(data, headers, status){
console.log(data);
res.render('views',{mydata:data})
},
function(err){
res.send(err);
});
});
app.listen(3000, function(){
console.log('Server started on 3000 Port');
})
i try to chenge something on congiration file of couchdb couchdb.init but it's not working
Upvotes: 0
Views: 25