MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / waitForJson

Function waitForJson

scripts/smoke-claw-code-desktop.mjs:68–85  ·  view source on GitHub ↗
(url, attempts = 60, delayMs = 500)

Source from the content-addressed store, hash-verified

66}
67
68async function waitForJson(url, attempts = 60, delayMs = 500) {
69 let lastError = null
70
71 for (let index = 0; index < attempts; index += 1) {
72 try {
73 const response = await fetch(url)
74 if (response.ok) {
75 return await response.json()
76 }
77 lastError = new Error(`${url} returned ${response.status}`)
78 } catch (error) {
79 lastError = error
80 }
81 await sleep(delayMs)
82 }
83
84 throw lastError || new Error(`等待 ${url} 超时。`)
85}
86
87async function postJson(url, body) {
88 const response = await fetch(url, {

Callers 2

waitForCompletedTurnFunction · 0.70
mainFunction · 0.70

Calls 1

sleepFunction · 0.70

Tested by

no test coverage detected