MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / httpGetJson

Function httpGetJson

tests/e2e/smoke/chart-runtime.smoke.test.js:259–284  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

257}
258
259function httpGetJson(url) {
260 return new Promise((resolve, reject) => {
261 const req = http.get(url, (response) => {
262 let body = ''
263 response.setEncoding('utf8')
264 response.on('data', (chunk) => {
265 body += chunk
266 })
267 response.on('end', () => {
268 if (response.statusCode !== 200) {
269 reject(new Error(`HTTP ${response.statusCode}`))
270 return
271 }
272 try {
273 resolve(JSON.parse(body))
274 } catch (error) {
275 reject(error)
276 }
277 })
278 })
279 req.on('error', reject)
280 req.setTimeout(2000, () => {
281 req.destroy(new Error('timeout'))
282 })
283 })
284}
285
286async function waitFor(fn, timeoutMs, label) {
287 const start = Date.now()

Callers 1

getRendererDebuggerUrlFunction · 0.85

Calls 6

resolveFunction · 0.85
onMethod · 0.80
parseMethod · 0.80
setTimeoutMethod · 0.80
destroyMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected