I'm currently utilizing PouchDB in conjunction with Express for retrieving documents from a database:
server.js:
var express = require('express')
var PouchDB = require('pouchdb')
var app = express()
var db = new PouchDB('vuedb')
// handling PouchDB operations
app.get('/docs', function(req, res) {
function map (doc, emit) {
if (doc.type === 'project') {
emit(doc.createdAt)
}
}
db.query(map, {include_docs: true}).then(function (projects) {
// _.map(projects.rows, (project) => (project.doc))
console.log('PROJECTS', projects)
})
// res.send()
})
client.js:
submit () {
this.$http.get('http://localhost:8080/docs').then(response => {
// console.log(response) successfully logs the response, indicating that the submit() action is functioning
}).catch(err => console.log(err))
}
I am eager to verify whether the projects
are indeed being fetched. Nonetheless, the statement
console.log('PROJECTS', projects)
fails to display any output in the terminal. What could be causing this issue? Are there specific methods for logging information in Express?