Last active
May 31, 2020 00:37
-
-
Save reichert621/b560585feef986323ffbd274e20567ba to your computer and use it in GitHub Desktop.
Taro Example: Check if an item is in stock
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 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