| 87 | } |
| 88 | |
| 89 | const replayFetch = (fetchData: { |
| 90 | method: string |
| 91 | url: string |
| 92 | headers: { [key: string]: string } |
| 93 | body: any |
| 94 | }): ResponseData => { |
| 95 | const serializedRequest = JSON.stringify(fetchData) |
| 96 | if (requestPlayback && requestPlayback.has(serializedRequest)) { |
| 97 | const responses = requestPlayback.get(serializedRequest) |
| 98 | if (responses.length !== 0) { |
| 99 | return responses.shift() |
| 100 | } |
| 101 | } |
| 102 | return { |
| 103 | error: { |
| 104 | type: FetchSyncErrorType.NO_RECORDED_REQUEST, |
| 105 | message: 'Run program to make requests.', |
| 106 | }, |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | const syncFetch = (method: string, url: string, headers: any, body: any): ResponseData => { |
| 111 | let objHeaders = {} |