Skip to content

Instantly share code, notes, and snippets.

@anuraghazra
Last active October 27, 2020 11:48
Show Gist options
  • Save anuraghazra/c1821a11219a30c8e09c2cf0c2dcdb13 to your computer and use it in GitHub Desktop.
Save anuraghazra/c1821a11219a30c8e09c2cf0c2dcdb13 to your computer and use it in GitHub Desktop.

Network Requests

There are a few ways to get info from an API


What is await?

'''ts const response = await fetch("mysite.com/api/dogs") '''

import React from "react";

export type AllowedTypes = string | number; export type Props = { value: T; };

export function Box( props: React.PropsWithChildren<Props>, ) { return

{props.value}

; }

<Box value={"10"} />; // ok. <Box value={"10"} />; // Type 'boolean' does not satisfy the constraint 'AllowedTypes'. <Box value={"10"} />; // Type 'string' is not assignable to type 'number'.


How do Promises work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment