Skip to content
Skillv1.0.0

frontend-api-integration-patterns-v2

Frontend API Integration Patterns workflow skill. Use this skill when the user needs Production-ready patterns for integrating frontend applications with backend APIs, including race condition handlin

by diegosouzapw(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from diegosouzapw/awesome-omni-skills (skills/frontend-api-integration-patterns-v2/SKILL.md). Install upstream with npx skills add diegosouzapw/awesome-omni-skills --skill frontend-api-integration-patterns-v2. Copyright stays with the author.

Frontend API Integration Patterns

Overview

This public intake copy packages plugins/antigravity-awesome-skills/skills/frontend-api-integration-patterns from https://github.com/sickn33/antigravity-awesome-skills into the native Omni Skills editorial shape without hiding its origin.

Use it when the operator needs the upstream workflow, support files, and repository context to stay intact while the public validator and private enhancer continue their normal downstream flow.

This intake keeps the copied upstream files intact and uses the external_source block in metadata.json plus ORIGIN.md as the provenance anchor for review.

Frontend API Integration Patterns

Imported source sections that did not map cleanly to the public headings are still preserved below or in the support files. Notable imported sections: Core Patterns, Anti-Patterns, Common Pitfalls, Limitations.

When to Use This Skill

Use this section as the trigger filter. It should make the activation boundary explicit before the operator loads files, runs commands, or opens a pull request.

  • 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
  • Use when the request clearly matches the imported source intent: Production-ready patterns for integrating frontend applications with backend APIs, including race condition handling, request cancellation, retry strategies, error normalization, and UI state management.

Operating Table

Situation Start here Why it matters
First-time use metadata.json Confirms repository, branch, commit, and imported path through the external_source block before touching the copied workflow
Provenance review ORIGIN.md Gives reviewers a plain-language audit trail for the imported source
Workflow execution SKILL.md Starts with the smallest copied file that materially changes execution
Supporting context SKILL.md Adds the next most relevant copied source file without loading the entire package
Handoff decision ## Related Skills Helps the operator switch to a stronger native skill when the task drifts

Workflow

This workflow is intentionally editorial and operational at the same time. It keeps the imported source useful to the operator while still satisfying the public intake standards that feed the downstream enhancer flow.

  1. Confirm the user goal, the scope of the imported workflow, and whether this skill is still the right router for the task.
  2. Read the overview and provenance files before loading any copied upstream support files.
  3. Load only the references, examples, prompts, or scripts that materially change the outcome for the current request.
  4. Execute the upstream workflow while keeping provenance and source boundaries explicit in the working notes.
  5. Validate the result against the upstream expectations and the evidence you can point to in the copied files.
  6. Escalate or hand off to a related skill when the work moves out of this imported workflow's center of gravity.
  7. Before merge or closure, record what was used, what changed, and what the reviewer still needs to verify.

Imported Workflow Notes

Imported: 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.


Imported: 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 transient failures (5xx or network errors).

const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

const fetchWithBackoff = async (fn, retries = 3, delay = 300) => {
  try {
    return await fn();
  } catch (err) {
    const isAbort = err.name === "AbortError";
    const isHttpError = typeof err.status === "number";
    const isRetryable = !isAbort && (!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);
  }
};

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();

export const dedupedFetch = (key, fn) => {
  if (inFlight.has(key)) return inFlight.get(key);

  const promise = fn().finally(() => inFlight.delete(key));
  inFlight.set(key, promise);
  return promise;
};

Examples

Example 1: Ask for the upstream workflow directly

Use @frontend-api-integration-patterns-v2 to handle <task>. Start from the copied upstream workflow, load only the files that change the outcome, and keep provenance visible in the answer.

Explanation: This is the safest starting point when the operator needs the imported workflow, but not the entire repository.

Example 2: Ask for a provenance-grounded review

Review @frontend-api-integration-patterns-v2 against metadata.json and ORIGIN.md, then explain which copied upstream files you would load first and why.

Explanation: Use this before review or troubleshooting when you need a precise, auditable explanation of origin and file selection.

Example 3: Narrow the copied support files before execution

Use @frontend-api-integration-patterns-v2 for <task>. Load only the copied references, examples, or scripts that change the outcome, and name the files explicitly before proceeding.

Explanation: This keeps the skill aligned with progressive disclosure instead of loading the whole copied package by default.

Example 4: Build a reviewer packet

Review @frontend-api-integration-patterns-v2 using the copied upstream files plus provenance, then summarize any gaps before merge.

Explanation: This is useful when the PR is waiting for human review and you want a repeatable audit packet.

Imported Usage Notes

Imported: Examples

Example 1: ML Prediction with Cancellation

const controllerRef = useRef(null);

const handlePredict = async (input) => {
  controllerRef.current?.abort();
  controllerRef.current = new AbortController();

  try {
    const result = await fetchWithBackoff(() =>
      apiClient("/predict", {
        method: "POST",
        body: JSON.stringify({ text: input }),
        signal: controllerRef.current.signal,
      })
    );

    setOutput(result);
  } catch (err) {
    if (err.name === "AbortError") return;
    setError(err.message);
  }
};

Example 2: Debounced Search

const debouncedQuery = useDebounce(query, 400);

useEffect(() => {
  if (!debouncedQuery) return;

  const controller = new AbortController();

  searchAPI(debouncedQuery, { signal: controller.signal })
    .then(setResults)
    .catch((err) => {
      if (err.name !== "AbortError") {
        setError("Search failed. Please try again.");
      }
    });

  return () => controller.abort();
}, [debouncedQuery]);

Example 3: Optimistic UI Update

const deleteItem = async (id) => {
  const previous = items;

  setItems((curr) => curr.filter((item) => item.id !== id));

  try {
    await apiClient(`/items/${id}`, { method: "DELETE" });
  } catch (err) {
    setItems(previous);
    setError("Delete failed. Please try again.");
  }
};

Best Practices

Treat the generated public skill as a reviewable packaging layer around the upstream repository. The goal is to keep provenance explicit and load only the copied source material that materially improves execution.

  • ✅ Centralize API logic in a dedicated layer
  • ✅ Normalize errors using a custom error class
  • ✅ Always handle loading, error, and success states
  • ✅ Use AbortController for request cancellation
  • ✅ Retry only transient failures (5xx)
  • ✅ Use debouncing for input-driven APIs
  • ✅ Deduplicate identical requests

Imported Operating Notes

Imported: Best Practices

  • ✅ Centralize API logic in a dedicated layer
  • ✅ Normalize errors using a custom error class
  • ✅ Always handle loading, error, and success states
  • ✅ Use AbortController for request cancellation
  • ✅ Retry only transient failures (5xx)
  • ✅ Use debouncing for input-driven APIs
  • ✅ Deduplicate identical requests

Troubleshooting

Problem: The operator skipped the imported context and answered too generically

Symptoms: The result ignores the upstream workflow in plugins/antigravity-awesome-skills/skills/frontend-api-integration-patterns, fails to mention provenance, or does not use any copied source files at all. Solution: Re-open metadata.json, ORIGIN.md, and the most relevant copied upstream files. Check the external_source block first, then restate the provenance before continuing.

Problem: The imported workflow feels incomplete during review

Symptoms: Reviewers can see the generated SKILL.md, but they cannot quickly tell which references, examples, or scripts matter for the current task. Solution: Point at the exact copied references, examples, scripts, or assets that justify the path you took. If the gap is still real, record it in the PR instead of hiding it.

Problem: The task drifted into a different specialization

Symptoms: The imported skill starts in the right place, but the work turns into debugging, architecture, design, security, or release orchestration that a native skill handles better. Solution: Use the related skills section to hand off deliberately. Keep the imported provenance visible so the next skill inherits the right context instead of starting blind.

Related Skills

  • @00-andruia-consultant - Use when the work is better handled by that native specialization after this imported skill establishes context.
  • @00-andruia-consultant-v2 - Use when the work is better handled by that native specialization after this imported skill establishes context.
  • @10-andruia-skill-smith - Use when the work is better handled by that native specialization after this imported skill establishes context.
  • @10-andruia-skill-smith-v2 - Use when the work is better handled by that native specialization after this imported skill establishes context.

Additional Resources

Use this support matrix and the linked files below as the operator packet for this imported skill. They should reflect real copied source material, not generic scaffolding.

Resource family What it gives the reviewer Example path
references copied reference notes, guides, or background material from upstream references/n/a
examples worked examples or reusable prompts copied from upstream examples/n/a
scripts upstream helper scripts that change execution or validation scripts/n/a
agents routing or delegation notes that are genuinely part of the imported package agents/n/a
assets supporting assets or schemas copied from the source package assets/n/a

Imported Reference Notes

Imported: Additional Resources


Imported: Anti-Patterns

  • ❌ Retrying 4xx errors
  • ❌ No request cancellation (memory leaks)
  • ❌ Race-condition-prone state updates
  • ❌ Swallowing errors silently
  • ❌ Global loading/error state for multiple requests
  • ❌ Calling APIs directly inside components repeatedly

Imported: Common Pitfalls

Problem: UI shows stale data Solution: Use cancellation or guard against outdated responses

Problem: Too many API calls on input Solution: Use debouncing + cancellation

Problem: Duplicate requests from multiple components Solution: Use request deduplication

Problem: Server overload during retry Solution: Use exponential backoff

Problem: State updates after component unmount Solution: Use AbortController cleanup


Imported: Limitations

  • These examples use vanilla JavaScript patterns; adapt them to your framework's data-fetching library when using React Query, SWR, Apollo, Relay, or similar tools.
  • Do not retry non-idempotent mutations unless the backend provides idempotency keys or another duplicate-safe contract.
  • Do not expose privileged API keys in frontend code; proxy sensitive requests through a backend.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/diegosouzapw-awesome-omni-skills-frontend-api-integratio-babc61/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

diegosouzapw-awesome-omni-skills-frontend-api-integratio-babc61.ocm.jsonjson
{
  "ocm": "1",
  "id": "diegosouzapw-awesome-omni-skills-frontend-api-integratio-babc61",
  "kind": "skill",
  "name": "frontend-api-integration-patterns-v2",
  "description": "Frontend API Integration Patterns workflow skill. Use this skill when the user needs Production-ready patterns for integrating frontend applications with backend APIs, including race condition handling, request cancellation, retry strategies, error normalization, and UI state management and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off.",
  "publisher": "diegosouzapw",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "frontend",
      "api-integration",
      "javascript",
      "react",
      "async",
      "frontend-api-integration-patte",
      "production-ready",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Frontend API Integration Patterns workflow skill. Use this skill when the user needs Production-ready patterns for integrating frontend applications with backend APIs, including race condition handling, request cancellation, retry strategies, error normalization, and UI state management and the operator should preserve the upstream workflow, copied support files, and provenance before merging or handing off."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/diegosouzapw/awesome-omni-skills",
      "path": "skills/frontend-api-integration-patterns-v2/SKILL.md",
      "ref": "c3af0048b70a4b84b2f2324e2f7b7ae5206d89b2",
      "url": "https://github.com/diegosouzapw/awesome-omni-skills/blob/c3af0048b70a4b84b2f2324e2f7b7ae5206d89b2/skills/frontend-api-integration-patterns-v2/SKILL.md",
      "key": "diegosouzapw/awesome-omni-skills/skills/frontend-api-integration-patterns-v2/SKILL.md"
    }
  },
  "instructions": "# Frontend API Integration Patterns\n\n## Overview\n\nThis public intake copy packages `plugins/antigravity-awesome-skills/skills/frontend-api-integration-patterns` from `https://github.com/sickn33/antigravity-awesome-skills` into the native Omni Skills editorial shape without hiding its origin.\n\nUse it when the operator needs the upstream workflow, support files, and repository context to stay intact while the public validator and private enhancer continue their normal downstream flow.\n\nThis intake keeps the copied upstream files intact and uses the `external_source` block in `metadata.json` plus",
  "cost": {
    "context_tokens": 3785
  }
}

Fetch it by URL: GET /api/v1/registry/diegosouzapw-awesome-omni-skills-frontend-api-integratio-babc61/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.