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 express = require('express'); | |
const bodyParser = require('body-parser'); | |
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY); | |
const app = express(); | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ extended: true })); | |
const createOrder = (skuId, { email, name, address }) => { |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- ... --> | |
<!-- Add this script tag within the <head> tags! --> | |
<script src="https://js.stripe.com/v3"></script> | |
</head> | |
<body> |
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
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,500'); | |
* { | |
box-sizing: border-box; | |
} | |
html, | |
body { | |
font-family: 'Open Sans', 'Helvetica Neue', Arial, san-serif; | |
line-height: 1.15; |
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
// import ... | |
import './App.css'; // Import our new CSS | |
const STRIPE_API_KEY = 'pk_test_...'; | |
const createCharge = token => { | |
// ... | |
}; | |
const Form = props => { |
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 () => { | |
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}; | |
}; |
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 cheerio = require('cheerio'); | |
const _ = require('lodash'); | |
const scraper = async (threshold = 200) => { | |
const url = 'https://news.ycombinator.com/' | |
const {text: html} = await request.get(url); | |
const $ = cheerio.load(html); | |
const links = $('.storylink').map((i, el) => { | |
return {href: $(el).attr('href'), text: $(el).text()}; |
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 _ = require('lodash'); | |
const getRandomInspirationalQuote = async () => { | |
const {text: json} = await request.get('https://type.fit/api/quotes'); | |
const quotes = JSON.parse(json); | |
return _.sample(quotes); | |
}; |
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 ping = async () => { | |
const res = await request.get('https://taro-beta.herokuapp.com/api/ping'); | |
return res.body; | |
}; | |
// Run function and verify output | |
ping().then(console.log).catch(console.log); |
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}; |
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 _ = require('lodash'); | |
const getTopPosts = async (subreddit, options = {}) => { | |
const {count = 5, interval = 'week'} = options; | |
const sub = `https://www.reddit.com/r/${subreddit}/top.json?sort=top&t=${interval}`; | |
const res = await request.get(sub); | |
const {children: posts} = res.body.data; | |
return posts.slice(0, count).map((post) => { |