Questions tagged as 'express'

1
answer

Cast to ObjectId failed for value \ "private \" at path \ "_id \" for model \ "Product \"

Hi, I'm doing an API Rest with Nodejs and MongoDB and I have the following problem: { "message": "Error al realizar la petición: CastError: Cast to ObjectId failed for value \"private\" at path \"_id\" for model \"Product\""} I do not unde...
asked by 18.08.2018 / 11:44
1
answer

console.log with values and return undefined

var got = require('got') exports.coger = function (id){ let i; if (!id){ i = "Introduzca una id"; return i; } got('enlace privado').then(f => { let a = JSON.parse(f.body) console.log(a) if(a.error){ i = a.error...
asked by 13.08.2018 / 12:26
2
answers

Keep session on two routers

I have 2 routers, for the example router1 app.post('/consultas', function (req, res) { req.session.nombre = 'administrador'; console.log('prueba',req.session.nombre); // ahi la session se guarda bien }); router2 router.get(...
asked by 08.08.2018 / 01:36
1
answer

Install create-react-app in a sub-domain

I'm doing a project on React using the create react app command. I have my server with NodeJS and I want to install the project in the main domain like www.dominio.com (that's what I do). But I also want to install a test version on test.domon...
asked by 29.04.2018 / 13:45
1
answer

export result of a nodedels middelware to a static js file

I am working on NODEJS and express, in my middelware routes / md.js file I process a request to the database and as a result I have an ARRANGEMENT. I need that arrangement to be read by a static public / js / estatico.js file that is called d...
asked by 20.03.2018 / 04:26
2
answers

Fill table in nodejs (jade) of an sql query

I have this query getAnalisisDetallado: function(req, res, next) { var config = require('.././database/config'); // connect to your database sql.connect(config, function(err) { if (err) console.log(err);...
asked by 21.06.2017 / 22:59
1
answer

Enter several links with Jade

Good morning, I would like to know how I can put several "links" with Jade, I am doing it in the following way: doctype html html(lang="es") head title Powergraph meta(charset="utf-8") link(href="https://maxcdn....
asked by 14.04.2017 / 09:10
1
answer

include in template ejs

I'm doing a render recursive and quite simple in this way in express // index.js const VIEWS = __dirname + '/app/views/'; app.get('/', function (req, res) { res.render(VIEWS + 'includes/partials/body', {layout: VIEWS + 'dash...
asked by 15.03.2017 / 02:32
1
answer

Return a promise that contains an array with data from other promises

I am setting up a function in expresJS that using two simple functions execute two SQL queries using Knex to two different databases, but it must return as a response a promise. function qDB1(status_id) { return KnexDB1 .select() .from('...
asked by 18.01.2017 / 05:07
1
answer

Send an image using JSON in node.js (express) to an android device

I am trying to send an image to the client using a server in node.js. When I type the URL in a browser I take the image. However, when I want to get it on my cell phone, it does not appear. This is the code to send the url of the image: app...
asked by 09.01.2017 / 21:45