This file contains hidden or 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
| function fetchProtectedData(url, opts = {}) { | |
| let headers = { | |
| 'Content-Type': 'application/json', | |
| } | |
| if (JWT_TOKEN) { | |
| headers = { | |
| ...headers, | |
| 'Authorization': `Bearer ${JWT_TOKEN}`, | |
| } |
This file contains hidden or 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
| class ControlledInput extends React.Component { | |
| constructor(props) { | |
| super(props) | |
| this.state = { value: props.initialValue || '' } | |
| } | |
| componentDidUpdate(prevProps, prevState) { | |
| console.log(prevProps.initialValue, this.props.initialValue) | |
| if (prevProps.initialValue !== this.props.initialValue) { | |
| this.setState({ value: this.props.initialValue || '' }) |
This file contains hidden or 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
| // npm i animated-scroll-to --save | |
| // import animateScrollTo from 'animated-scroll-to'; | |
| <li className="nav-item"><Link onClick={ev => { | |
| console.log('clicked!') | |
| // document.getElementsByClassName('flex-bottom')[0].scrollTop=0 | |
| if (window.location.pathname === '/players') { | |
| ev.preventDefault() | |
| animateScrollTo(0, { | |
| element: document.querySelector('.flex-bottom'), | |
| }); |
This file contains hidden or 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
| function getUrbanAreas() { | |
| console.log(urbanAreaNames); | |
| let userInputUA = Object.keys(urbanAreaNames); | |
| for (let i = 0; i < userInputUA.length; i++) { | |
| let urbanAreaDropdownlist = `<option value="${urbanAreaNames[userInputUA[i]]}">${userInputUA[i]}</option>` | |
| $('#urbanAreas-Dropdown').append(urbanAreaDropdownlist); | |
| } | |
| $('#urbanAreas-Dropdown').chosen(); | |
| } | |
| function setupDropdownSubmit() { |
This file contains hidden or 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
| // https://www.npmjs.com/package/faker | |
| const faker = require('faker') | |
| faker.seed(123); | |
| const { parse, stringify } = require('flatted/cjs'); | |
| function unique(fn, arr, objKey) { | |
| const value = fn() | |
| const exists = arr.find(item => item[objKey] === value) | |
| if (exists !== undefined) { |
This file contains hidden or 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 persons =[{ | |
| id: 'aBcDeFgH', | |
| firstName: 'Juan', | |
| lastName: 'Doe', | |
| age: 32 | |
| }, | |
| { | |
| id: 'zYxWvUt', | |
| firstName: 'Alex', | |
| lastName: 'Smith', |
REQ:
- URL (protocol:://host/path?queryString) https://localhost:8888/hangouts?username=Tudor&ref=ad-campaign
- method (GET, POST, PUT, PATCH, DELETE, OPTIONS)
- headers
- maybe a REQ body (for POST, PUT, PATCH)
RESP
- status code
This file contains hidden or 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 app = express() | |
| // NOTE the router should go into its own file and do | |
| // module.exports = usersRouter; | |
| const usersRouter = express.Router(); | |
| usersRouter.route('/id/:id') | |
| .get((req, res, next) => { | |
| res.status(200).json({ message: 'Hello' }) | |
| }) |
In these drills, you'll practice executing basic CRUD (create, read, update, delete) operations in the psql shell.
Before you get started, download this SQL data dump. Create and populate a new database using the data dump (make sure to update the path with the location where you saved the file):
psql -U dunder_mifflin_admin -d restaurants-app -f ~/Downloads/nyc-restaurants-data-backup.sqlTake a moment to get familiar with this new database. You can use \dt+ to see a list of public tables and \d <TABLENAME> to see a description of those tables.
