ChemPal Documentation - v1.6.0
    Preparing search index...
    • Validates if a URL is an authentication check endpoint. These endpoints are used to verify the user's authentication status and will return a specific error code (1005) if authentication fails.

      Parameters

      • url: string

        The API endpoint URL to check

      Returns boolean

      True if the endpoint is used for auth checks

      if (isAuthCheckEndpoint("/api/user/info")) {
      // Handle potential 1005 auth failure response
      }
      export function isAuthCheckEndpoint(url: string): boolean {
      // Widen the enum-value array to string[] so .includes accepts an
      // arbitrary string argument (the array element type is the enum union).
      return (
      [
      ApiEndpoints.USER_INFO,
      ApiEndpoints.FRUIT_HEAD,
      ApiEndpoints.FAVOURITE_ADD,
      ApiEndpoints.FRUIT_ADD,
      ] as string[]
      ).includes(url);
      }