Skip to content

Instantly share code, notes, and snippets.

@reichert621
Last active May 31, 2020 00:37
Show Gist options
  • Save reichert621/b560585feef986323ffbd274e20567ba to your computer and use it in GitHub Desktop.
Save reichert621/b560585feef986323ffbd274e20567ba to your computer and use it in GitHub Desktop.
Taro Example: Check if an item is in stock
const request = require('superagent');
const checkItemInStock = async () => {
// Checks to see if the product in the URL below is in stock
const {text: html} = await request.get(
'https://www.bowflex.com/selecttech/552/100131.html'
);
const inStock = html.toLowerCase().indexOf('out of stock') === -1;
return {inStock};
};
// Run function and verify output
checkItemInStock().then(console.log).catch(console.log);
const main = () => checkItemInStock();
// You must have a default export of the function you want to run
// in order for it to be deployed and scheduled
module.exports = main;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment