forked from TechBowl-japan/react-stations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch.ts
35 lines (35 loc) · 892 Bytes
/
fetch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
export const imageUrl = 'https://avatars.githubusercontent.com/u/298748'
export const mockServerResponse = {
message: imageUrl,
status: 'success',
}
export const mockResponse: Response = {
headers: {} as any,
ok: true,
redirected: false,
status: 200,
statusText: 'OK',
trailer: {} as any,
type: 'default',
body: null,
url: '',
bodyUsed: false,
arrayBuffer() {
throw new Error('unimplemented; You are doing something wrong.')
},
blob() {
throw new Error('unimplemented; You are doing something wrong.')
},
formData() {
throw new Error('unimplemented; You are doing something wrong.')
},
json() {
return Promise.resolve(JSON.parse(JSON.stringify(mockServerResponse)))
},
text() {
return Promise.resolve(JSON.stringify(mockServerResponse))
},
clone() {
throw new Error('unimplemented; You are doing something wrong.')
},
}