(url: URL, timeout: number, data: any)
| 32 | } |
| 33 | |
| 34 | const callbackRequest = (url: URL, timeout: number, data: any) => { |
| 35 | data = JSON.stringify(data) |
| 36 | const options: http.RequestOptions = { |
| 37 | hostname: url.hostname, |
| 38 | port: url.port, |
| 39 | path: url.pathname, |
| 40 | timeout, |
| 41 | method: 'POST', |
| 42 | headers: { |
| 43 | 'Content-Type': 'application/json', |
| 44 | 'Content-Length': data.length, |
| 45 | }, |
| 46 | } |
| 47 | const req = http.request(options) |
| 48 | req.on('timeout', () => { |
| 49 | console.warn('Callback request timed out.') |
| 50 | req.abort() |
| 51 | }) |
| 52 | req.on('error', e => { |
| 53 | console.error('Callback request error.', e) |
| 54 | req.abort() |
| 55 | }) |
| 56 | req.write(data) |
| 57 | req.end() |
| 58 | } |
| 59 | |
| 60 | const getContent = ( |
| 61 | objName: string, |
no test coverage detected
searching dependent graphs…