Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .post(function (req, res) {
  2.             var planet = new Planet(req.body);
  3.             Planet.find({name: planet.name}, function (err, planet) {
  4.                 if (err) {
  5.                     res.status(500).send(err);
  6.                 }
  7.                 if (planet == '') {
  8.                     console.log("action: planet not found");
  9.                     //download data from swapi here
  10.                     // planet.save();
  11.                 } else {
  12.                     //send data back
  13.                     console.log("action: planet found");
  14.                     res.status(201).send(planet);
  15.                 }
  16.             })
  17.         })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement