Hello Team, How I can intercept different errors f...
# gooddata-ui
Hello Team, How I can intercept different errors for eg. 404, 401 on the frontend application from gooddata-cn Apis to show user friendly messages as per the status code
Hi there. In generic terms, when you make an async API call through your frontend application, it is possible to present different information based upon the HTTP status code received (and other details of the JSON response). Are you using React or a similar framework for your frontend? It would be good to see an example code snippet of what you’re trying to do to be able to get more specific.
Hello @Jan Rehanek Error code which I am getting is
Copy code
  "abeType": "NAuth",
  "cause": {
    "message": "Request failed with status code 401",
    "name": "Error",
    "stack": "Error: Request failed with status code 401\n    at createError (<https://localhost.gcp.cwan.cloud:3001/reporting/static/js/vendors~main.chunk.js:1250498:15>)\n    at settle (<https://localhost.gcp.cwan.cloud:3001/reporting/static/js/vendors~main.chunk.js:1250732:12>)\n    at XMLHttpRequest.onloadend (<https://localhost.gcp.cwan.cloud:3001/reporting/static/js/vendors~main.chunk.js:1249901:7>)",
    "config": {
      "url": "/api/profile",
      "method": "get",
      "headers": {
        "Accept": "application/json, text/plain, */*",
        "X-Requested-With": "XMLHttpRequest"
      "baseURL": "<https://gooddata-cn-test.cloud>",
      "transformRequest": [
      "transformResponse": [
      "timeout": 0,
      "withCredentials": true,
      "xsrfCookieName": "XSRF-TOKEN",
      "xsrfHeaderName": "X-XSRF-TOKEN",
      "maxContentLength": -1,
      "maxBodyLength": -1,
      "transitional": {
        "silentJSONParsing": true,
        "forcedJSONParsing": true,
        "clarifyTimeoutError": false
  "authenticationFlow": {
    "loginUrl": "/appLogin",
    "returnRedirectParam": "redirectTo"
there is no key which has status code
Hi @Jitender Singh - I’ve already sent you the same reply in a DM, but just to share it with others: We have bunch of type guards to check the particular error type (in this case
) see: https://github.com/gooddata/gooddata-ui-sdk/blob/master/libs/sdk-backend-spi/src/errors/index.ts#L274 Is this sufficient? Or what is the use case for getting the http status? (we have it only in
Copy code
export function isNotAuthenticated(obj: unknown): obj is NotAuthenticated {