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 _ = 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 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 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
// 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
@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
<!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
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
// Load environment variables from our `.env` file | |
require('dotenv').config(); | |
const path = require('path'); | |
const express = require('express'); | |
// Make sure your STRIPE_SECRET_KEY exists as an environment variable! | |
// This should look something like `sk_test_xxxxxxxxxxxxxxxxxxxxxxxxx` | |
// and can be found at https://dashboard.stripe.com/test/apikeys | |
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY); |
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 request from 'superagent'; | |
import React from 'react'; | |
import StripeCheckout from 'react-stripe-checkout'; | |
// Replace with your public key (https://dashboard.stripe.com/test/apikeys) | |
const STRIPE_API_KEY = 'pk_test_xxx'; | |
const createOrder = (skuId, customer) => { | |
const { email, name, address } = customer; |