Last active
February 2, 2018 01:07
-
-
Save jordanluyke/ed2d9e4bb08d659434dbdb98fba5bb93 to your computer and use it in GitHub Desktop.
Bonusly spam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Rx = require('rxjs') | |
const request = require('request') | |
const apiKey = "" | |
const count = 50 | |
const delay = 1000 | |
const reason = "@tyson +1 architecture overview #vision" | |
Rx.Observable.range(0, count) | |
.flatMap(n => { | |
return Rx.Observable.create(observer => { | |
request({ | |
url: "https://bonus.ly/api/v1/bonuses", | |
method: "POST", | |
headers: { | |
"Authorization": "Bearer " + apiKey | |
}, | |
body: { | |
reason: reason | |
}, | |
json: true | |
}, (err, res, body) => { | |
console.log(n) | |
if(err) | |
observer.error(err) | |
else if(!("" + res.statusCode).match(/2\d{2}/g)) | |
observer.error(res) | |
else | |
observer.next(res) | |
}) | |
}) | |
.delay(n * delay) | |
}) | |
.subscribe(Void => {}, err => console.error("Error:", err.body)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment