Created
November 25, 2015 08:50
-
-
Save lejoss/6cc0e2531d1b6a2228f3 to your computer and use it in GitHub Desktop.
bloqueo tecnico!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('superagent'); | |
// middleware requesting Flask API | |
function calculeClawfull(req, res, next) { | |
var param = req.params.rate; | |
var url = 'http://localhost:5000/clawfull/' + param; | |
// using superagent | |
request | |
.get(url) | |
.end(function(err, res) { | |
if(res.status == 200) { | |
console.log(res.text); // la respuesta me trae lo que quiero desde el Flask eg. [[2,6], [33,7], ...] | |
// el bloqueo que tengo es que no he podido sacar esta data del middleware | |
// y pasarselo a la ruta(endpoint) para poder retornarla al cliente | |
// yo he intentado cosas como req.newProp = req.text pero no me sirve | |
// osea estoy atrapado en el middleware :( | |
} else { console.log('WOOOT something is broken >,< '); } | |
}); | |
next(); // que tiene este next() ?, yo se que el next llama a la siguiente ruta(endpoint) | |
// pero no se como sacar la data de este middleware y usarla en la ruta(endpoint) | |
// deberia ser transparente ? | |
} | |
app.get('/api/clawfull/:rate', calculeClawfull, function(req, res, next) { | |
// como llega la data del middleware aca ? | |
// para hacer algo como res.json(...) y regresar la data al cliente | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment