Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Promise = require('bluebird');
  2. const request = require('request');
  3. const arequest = Promise.PromisifyAll(request);
  4.  
  5. const getAndStoreBoobies = Promise.coroutine(function* (id, threshold){
  6.     var resp, json;
  7.     resp = (yield arequest.getAsync('http://www.myboobies.com/' + id)).body;
  8.     json = JSON.parse(resp);
  9.     if (json.bra_size <= threshold){
  10.         return;
  11.     }
  12.     const options = {
  13.         url: 'http://www.mybobbiesstorage.com/api/dump',
  14.         form: {
  15.             thumb: json.thumbnail,
  16.             bra_size: json.bra_size,
  17.             name: json.name
  18.         }
  19.     };
  20.     resp = (yield arequest.postAsync(options)).body;
  21.     json = JSON.parse(resp);   
  22.     if (json.error){
  23.         console.log("boobies not saved: ", json.error);
  24.     } else {
  25.         console.log("All good!");
  26.     }
  27. });
  28.  
  29. getAndStoreBoobies('EdithPiaf', 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement