frontend-api-integration-patterns
하는 일
이 도구는 웹사이트나 앱을 다른 온라인 서비스에 더 안정적으로 연결하도록 돕습니다. 정보를 주고받을 때 생기는 흔한 문제를 처리하는 방법을 가르쳐, 사용자에게 모든 것이 부드럽고 오류 없이 작동하도록 합니다.
사용하는 경우
- ✓웹사이트를 데이터 서비스에 연결할 때.
- ✓새 정보를 가져오는 동안 오래된 정보가 화면에 보이지 않도록 하고 싶을 때.
- ✓데이터를 불러오거나 보낼 때 생기는 오류를 고쳐야 할 때.
스킬 링크
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/frontend-api-integration-patterns/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“새 정보를 가져오는 동안 웹사이트에 오래된 데이터가 보이지 않도록 하려면 어떻게 하나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
서비스와 통신하는 코드를 정리하고, 중복 요청이 전송되지 않도록 막으며, 연결이 실패하면 지능적으로 재시도할 수 있도록 합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Frontend API Integration Patterns
Overview
This skill provides production-ready patterns for integrating frontend applications with backend APIs.
Most frontend issues are not caused by APIs being difficult to call, but by incorrect handling of asynchronous behavior—leading to race conditions, stale data, duplicated requests, and poor user experience.
This skill focuses on correctness, resilience, and user experience, not just making API calls work.
When to Use This Skill
- Connecting frontend apps (React, React Native, Vue, etc.) to backend APIs
- Integrating ML/AI endpoints (
/predict,/recommend) - Handling asynchronous data in UI
- Fixing stale data, flickering UI, or duplicate requests
- Designing scalable frontend API layers
Core Patterns
1. API Layer (Separation of Concerns)
Centralize API logic and normalize errors.
export class ApiError extends Error {
constructor(message, status, payload = null) {
super(message);
this.name = "ApiError";
this.status = status;
this.payload = payload;
}
}
export const apiClient = async (url, options = {}) => {
const res = await fetch(url, {
headers: { "Content-Type": "application/json" },
...options,
});
if (!res.ok) {
let payload = null;
try {
payload = await res.json();
} catch (_) {}
throw new ApiError(
payload?.message || "Request failed",
res.status,
payload
);
}
// handle empty responses safely (e.g. 204 No Content)
if (res.status === 204) return null;
const text = await res.text();
return text ? JSON.parse(text) : null;
};
2. Race-Safe State Management
Prevent stale responses from overwriting fresh data.
useEffect(() => {
let cancelled = false;
const load = async () => {
try {
setLoading(true);
setError(null);
const result = await getUser();
if (!cancelled) setData(result);
} catch (err) {
if (!cancelled) setError(err.message);
} finally {
if (!cancelled) setLoading(false);
}
};
load();
return () => {
cancelled = true;
};
}, []);
Use a cancellation flag for non-fetch async logic. For network requests, prefer AbortController.
3. Request Cancellation (AbortController)
Cancel in-flight requests to avoid memory leaks and stale updates.
useEffect(() => {
const controller = new AbortController();
const load = async () => {
try {
const data = await getUser({ signal: controller.signal });
setData(data);
} catch (err) {
if (err.name === "AbortError") return;
setError(err.message);
}
};
load();
return () => controller.abort();
}, [userId]);
4. Retry with Exponential Backoff
Retry only explicitly replay-safe operations and classified transient failures. The default performs one attempt. Do not classify arbitrary programming or parsing exceptions as network errors. Honor provider Retry-After and a total deadline in the real adapter; do not enable this simple backoff for rate-limit responses. The POST prediction example intentionally does not enable retries unless the backend contract independently guarantees replay safety.
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
const fetchWithBackoff = async (fn, retries = 3, delay = 300, replaySafe = false) => {
try {
return await fn();
} catch (err) {
const isAbort = err.name === "AbortError";
const isHttpError = typeof err.status === "number";
const isNetworkFailure = err.code === "NETWORK_ERROR";
const isRetryable = replaySafe && !isAbort &&
(isNetworkFailure || (isHttpError && err.status >= 500));
if (retries <= 0 || !isRetryable) throw err;
const nextDelay = delay * 2 + Math.random() * 100;
await sleep(nextDelay);
return fetchWithBackoff(fn, retries - 1, nextDelay, replaySafe);
}
};
5. Debounced API Calls
Avoid excessive API calls (e.g., search inputs).
const useDebounce = (value, delay = 400) => {
const [debounced, setDebounced] = useState(value);
useEffect(() => {
const t = setTimeout(() => setDebounced(value), delay);
return () => clearTimeout(t);
}, [value, delay]);
return debounced;
};
6. Request Deduplication
Prevent duplicate API calls across components.
const inFlight = new Map();
…
자주 묻는 질문
「레이스 컨디션」이란 무엇인가요?
두 개 이상의 작업이 동시에 일어나고, 그 작업이 끝나는 순서 때문에 예상치 못한 잘못된 결과가 생기는 현상입니다.
요청을 왜 취소하나요?
사용자가 응답이 오기 전에 화면을 떠나는 경우 등에 오래되었거나 잘못된 정보가 표시되는 것을 막기 위해서입니다.
「재시도 전략」이란 무엇인가요?
작업이 실패하면 시간을 두고 다시 시도하는 방법입니다. 매번 대기 시간을 조금씩 늘려서 일시적인 연결 문제를 처리합니다.
상세 정보
작성자의 원본 설명
Production-ready patterns for integrating frontend applications with backend APIs, including race condition handling, request cancellation, retry strategies, error normalization, and UI state management.
인기도
- GitHub 스타
- 48k
- 순위
- #4661
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
00-andruia-consultant
48k에이전트가 AI 프로젝트를 시작하거나 개선할 수 있도록 코드를 분석하고 스페인어로 실행 계획을 세워 줍니다.
007
48k에이전트가 보안 감사와 위협 모델링을 수행해 공격과 취약점으로부터 프로젝트를 보호하도록 돕습니다.
10-andruia-skill-smith
48k에이전트가 AI 도구의 작동 방식을 정의하고 문서를 쓰며 구조를 검증하도록 돕습니다.
20-andruia-niche-intelligence
48k에이전트가 신뢰할 수 있는 자료를 바탕으로 특정 산업의 맥락, 규칙, 사용 패턴, 위험을 정리한 요약을 만들도록 돕습니다.
비슷한 스킬
angular-developer
280k에이전트가 Angular 코드를 만들고 프로젝트 구조를 조언하도록 돕습니다. 새 프로젝트 시작, 코드 부분 생성, 성능과 접근성 개선에 유용합니다.
frontend-a11y
280k모든 사람이 웹 인터페이스를 쓸 수 있도록 에이전트를 돕습니다. 웹사이트와 앱이 화면 읽기 프로그램과 키보드 탐색에서 잘 작동하도록 합니다.
frontend-patterns
280k프론트엔드 개발의 현대적인 패턴을 적용하도록 에이전트를 돕습니다. React와 Next.js에서 성능을 최적화하고, 상태를 관리하며, 모범 사례를 따릅니다.