Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Promise = require('bluebird');
- const request = require('request');
- const arequest = Promise.PromisifyAll(request);
- const getAndStoreBoobies = Promise.coroutine(function* (id, threshold){
- var resp, json;
- resp = (yield arequest.getAsync('http://www.myboobies.com/' + id)).body;
- json = JSON.parse(resp);
- if (json.bra_size <= threshold){
- return;
- }
- const options = {
- url: 'http://www.mybobbiesstorage.com/api/dump',
- form: {
- thumb: json.thumbnail,
- bra_size: json.bra_size,
- name: json.name
- }
- };
- resp = (yield arequest.postAsync(options)).body;
- json = JSON.parse(resp);
- if (json.error){
- console.log("boobies not saved: ", json.error);
- } else {
- console.log("All good!");
- }
- });
- getAndStoreBoobies('EdithPiaf', 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement