Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "wordpress-packages/utils/lib/factory/ajax/corruptRestApi"

Index

Variables

Const NOTICE_ATTRIBUTE_NAMESPACE

NOTICE_ATTRIBUTE_NAMESPACE: "data-namespace" = "data-namespace"

Const NOTICE_ID

NOTICE_ID: "notice-corrupt-rest-api" = "notice-corrupt-rest-api"

Const handleCorrupRestApi

handleCorrupRestApi: handleCorruptRestApi = handleCorruptRestApi
deprecated

For backwards-compatibility.

Functions

addCorruptRestApi

  • addCorruptRestApi(__namedParameters: { method: string }, addNamespaceImmediate?: string): void
  • Set a request as failing so the endpoint is probably corrupt (see corruptRestApi.tsx)

    Please consider the following:

    The fetch() function will automatically throw an error for network errors but not for HTTP errors such as 4xx or 5xx responses.

    see

    https://jasonwatmore.com/post/2021/10/09/fetch-error-handling-for-failed-http-responses-and-network-errors

    Parameters

    • __namedParameters: { method: string }
      • method: string
    • Optional addNamespaceImmediate: string

    Returns void

addCorruptRestApiLog

  • addCorruptRestApiLog(__namedParameters: { method: ERouteHttpVerb; ms: number; response: string; route: string }): void
  • Parameters

    • __namedParameters: { method: ERouteHttpVerb; ms: number; response: string; route: string }

    Returns void

addToNotice

  • addToNotice(namespace: string, onlyWhen?: (Anonymous function)): Promise<void>
  • Parameters

    • namespace: string
    • Default value onlyWhen: (Anonymous function) = async () => {}

    Returns Promise<void>

handleCorruptRestApi

  • handleCorruptRestApi(resolve: Record<string, () => Promise<void>>): void
  • Register a new endpoint which needs to resolve to a valid JSON result. In this way we can detect a corrupt REST API namespace e. g. it is blocked through a security plugin.

    This function needs to be called in document.readyState < completed!

    Parameters

    • resolve: Record<string, () => Promise<void>>

    Returns void

removeCorruptRestApi

  • removeCorruptRestApi(namespace: string): Promise<void>
  • Parameters

    • namespace: string

    Returns Promise<void>

Generated using TypeDoc