View difference between Paste ID: JU6bpjDb and kUVWZWsD
SHOW: | | - or go back to the newest paste.
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
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'
13+
		url: 'http://www.mybobbiesstorage.com/api/dump',
14
		form: {
15-
			thumb: json.thumbnail
15+
			thumb: json.thumbnail,
16-
			bra_size: json.bra_size
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);