Marco Acosta / 10/06/2017
WHERE WAS HE LAST?
what is 'WHERE WAS HE LAST'?
this app is about where to find the last location of your favorite super hero.
https://drive.google.com/open?id=0B6TZXvKSDHTWZnhJVnhEM0l5bG8
My idea is to use a superhero api so i can have all superheroes there are and make an edit in one of my views where the user can find a super hero and type in the last location he/she saw that particular superhero last. Also add a list of superheroes that people have sighted with a location button where the user can input the location where they saw that particular superhero.
getting API to work was probably the hardest thing in this project for me. It took me 1 day to figure out.
day 2: folders setup
day 3: routes + controllers:
day 4:views
day 5: debugs
https://developer.marvel.com/documentation/authorization
I will add more features to this app such as a google api of the actual location in the world where the superhero was last sighted. Also i would like to add more api regarding the comics and issue of the superhero.
function makeRequest(req, res, next) {
console.log(req.body.name)
const name = req.body.name
const ts = Date.now()
const pubKey = process.env.MARVEL_PUBLIC_KEY
const privKey = process.env.MARVEL_PRIVATE_KEY
const hash = md5(ts + privKey + pubKey)
fetch(`http://gateway.marvel.com/v1/public/characters?name=${name}&ts=${ts}&apikey=${pubKey}&hash=${hash}`)
.then(res => res.json())
.then(jsonRes => {
// console.log(jsonRes);
// console.log(jsonRes.data.results);
res.locals.superheroes = jsonRes
res.locals.name = jsonRes.data.results[0].name;
res.locals.description = jsonRes.data.results[0].description;
res.locals.thumbnail = jsonRes.data.results[0].thumbnail.path + '.'+ jsonRes.data.results[0].thumbnail.extension;
next();
}).catch((err) => {
console.log(err);
res.locals.name = null;
res.locals.description = null;
res.locals.thumbnail = null;
next();
})
}
module.exports = {
makeRequest: makeRequest,
}