Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Too many requests when clicking on a resource for the first time or initially

Đang mở
#582 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
react, typescript
Lĩnh vực
api, frontend

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lần nhấp vào tài nguyên đầu tiên hoặc lần tải lại trang đầu tiên với thiết lập HydraAdmin, hydraDataProvider, httpClient tùy chỉnh và apiDocumentationParser được cung cấp, sau đó kiểm tra dấu vết mạng của trình duyệt. Theo dõi các request ban đầu qua data provider và các điểm vào của frontend; được xem là hoàn tất khi việc tải tài nguyên ban đầu không còn tạo ra các request trùng lặp không thể giải thích trong môi trường development hoặc production.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

API Platform version(s) affected: x.y.z

Backend

v3.3.12

Frontend

"@api-platform/admin": "^4.0.1",

Description
When I click on a resource for the first time a lot of requests will fire. Here I reload the page on a specific resource (http://localhost:3000/#/locations). We also tested in prod mode.

Dev Mode

Bildschirmfoto 2024-09-13 um 10 54 09

Prod Mode

Bildschirmfoto 2024-09-13 um 11 04 05

How to reproduce
Its a simple example. I just use a custom httpClient to set a header for the authorization (jwt).

import { HydraAdmin, hydraDataProvider } from "@api-platform/admin";
import { parseHydraDocumentation } from "@api-platform/api-doc-parser";
import { ENTRYPOINT } from "./constants/entrypoint";
import MyHeaders from "./constants/headers";
import httpClient from "./components/HttpClient";

// Replace with your own API entrypoint
// For instance if https://example.com/api/books is the path to the collection of book resources, then the entrypoint is https://example.com/api

const apiDocumentationParser = () => async () => {
  try {
    return await parseHydraDocumentation(ENTRYPOINT, {
      headers: MyHeaders
    });
  } catch (result) {
    // @ts-ignore
    const { api, response, status } = result;
    if (status !== 401 || !response) {
      throw result;
    }

    return {
      api,
      response,
      status,
    };
  }
};

const dataProvider = hydraDataProvider({
  entrypoint: ENTRYPOINT,
  httpClient: httpClient,
  apiDocumentationParser: apiDocumentationParser(),
  useEmbedded: false,
});

export default () => (
  <HydraAdmin dataProvider={dataProvider} />
);

Additional Context

Ngôn ngữ chính
TypeScript
Star
516
Fork
134
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của api-platform/admin

Tất cả issue của api-platform/admin

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.