MCPcopy Create free account
hub / github.com/basarat/typescript-book / getJSON

Function getJSON

code/types/generics.ts:48–60  ·  view source on GitHub ↗
(config: {
    url: string,
    headers?: { [key: string]: string },
  })

Source from the content-addressed store, hash-verified

46
47namespace ddd {
48 const getJSON = <T>(config: {
49 url: string,
50 headers?: { [key: string]: string },
51 }): Promise<T> => {
52 const fetchConfig = ({
53 method: 'GET',
54 'Accept': 'application/json',
55 'Content-Type': 'application/json',
56 ...(config.headers || {})
57 });
58 return fetch(config.url, fetchConfig)
59 .then<T>(response => response.json());
60 }
61
62 type LoadUsersResponse = {
63 users: {

Callers 1

loadUsersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected