Created
October 15, 2018 14:47
-
-
Save wouterds/e46134ade6c3480a325ea0285c108506 to your computer and use it in GitHub Desktop.
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 axios = require('axios'); | |
const chalk = require('chalk'); | |
const sleep = require('await-sleep'); | |
const checkCode = async (code) => { | |
const codes = [code]; | |
const response = await axios.post('https://winadrone.kelloggs.com/api/nl_BE/redemption/validate-codes', { codes }); | |
const { data } = response; | |
const valid = data.result[0].status !== 'Invalid'; | |
console.log(`Code ${chalk.white(code)} is ${valid ? chalk.green('valid') : chalk.red('invalid')}`); | |
if (valid) { | |
console.log(` token: ${chalk.yellow(data.token)}`); | |
} | |
await sleep(Math.random() * 100); | |
if (code < 10000) { | |
checkCode(code + 1); | |
} | |
}; | |
checkCode(0); |
Author
wouterds
commented
Oct 15, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment