(config: {
url: string,
headers?: { [key: string]: string },
})
| 46 | |
| 47 | namespace 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: { |