INNER CODE UNIT · JavaScript
timer
WJZ-P/gemini-skill · src/atlas-provider.js:27
const timer = setTimeout(() => controller.abort(), timeoutMs ?? config.atlasRequestTimeoutMs);
try {
const response = await fetch(joinUrl(config.atlasBaseUrl, path), {
method,
headers: {
Authorization: `Bearer ${finalApiKey}`,
'Content-Type': 'application/json',
},
body: body ? JSON.stringify(body) : undefined,
signal: controller.signal,
});
const { raw, data } = await parseJsonSafely(response);
if (!response.ok) {
const message = data?.error?.message || data?.msg || raw || `HTTP ${response.status}`;
throw new Error(`Atlas API 请求失败: ${response.status} ${message}`);
}