Skip to content

Instantly share code, notes, and snippets.

View davevanfleet's full-sized avatar

Dave Van Fleet davevanfleet

View GitHub Profile
import axios from 'axios';
import { useQuery } from 'react-query';
const useTeam = (id) => {
const getTeam = async () => {
const data = await axios.get(`/teams/${id}`);
return data;
}
const { data, isLoading } = useQuery(['team', id], getTeam);
import axios from 'axios';
import { useQuery } from 'react-query';
const useTeam = (id) => {
const query = async () => {
const data = await axios.get(`/teams/${id}`);
return data;
}
const { data, isLoading } = useQuery(['team', id], query);
import axios from 'axios';
import { useQuery } from 'react-query';
const query = async ({queryKey}) => {
const [_, id] = queryKey;
const data = await axios.get(`/teams/${id}`);
return data;
}
const useTeam = (id) => {
const useExercises = (muscleGroup) => {
const fetchExercises = async () => {
const data = await axios.get('/exercises', {params: {muscleGroup}});
return data;
}
const onError = (error) => {
console.error(error);
}
const { data, isLoading } = useQuery(
['exercises', muscleGroup],
const ExerciseList = () => {
const fetchBackExercises = async () => {
const data = await axios.get('/exercises', {params: {muscleGroup: 'back'}});
return data;
}
const onError = (error) => {
console.error(error);
}
const { data = [], isLoading } = useQuery(
['exercises', 'back'],
@davevanfleet
davevanfleet / fetchBackExercises.js
Last active April 18, 2022 02:48
fetchBackExercises.js
const fetchBackExercises = async () => {
const data = await axios.get('/exercises', {params: {muscleGroup: 'back'}});
return data;
}
const onError = (error) => {
console.error(error);
}
const { data, isLoading } = useQuery(
@davevanfleet
davevanfleet / createSubscription.py
Created February 10, 2021 15:36
Code snippet of flask app - Create subscription view function
# Endpoint for associating sucessfully created Stripe subscription
# with the Adult document. Needs body with paymentMethodId (from
# Stripe in frontend), priceId (from frontend, matches the priceId
# for selected option in Stripe), and childId (probably will be changed
# to create child here?)
@stripe_blueprint.route('/create_subscription', methods=['POST'])
def createSubscription():
body = request.get_json()
email = body["email"]
receives_emails = body["receivesEmails"]