Help to handle API 404 error

Hello Wapplers,

I’m try to handle external API call when there is 404 error.
I have Condition after API call api.resposne==200 which handle good when external API return 200, but when there is 404 error I see this message in output: {"errorCode":404,"message":"Device not found for specified identifier","activityId":"8f1925a7-dc7e-4d6e-bd82-955714eb0012"}
image
And errors in WebLogs:

  server-connect:server Got error? '{"errorCode":404,"message":"Device not found for specified identifier","activityId":"b7b1c30a-70b0-426c-8360-94593a182025"}' +13s
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at new NodeError (node:internal/errors:387:5)
    at ServerResponse.setHeader (node:_http_outgoing:644:11)
    at ServerResponse.header (/opt/node_app/node_modules/express/lib/response.js:794:10)
    at ServerResponse.send (/opt/node_app/node_modules/express/lib/response.js:174:12)
    at ServerResponse.json (/opt/node_app/node_modules/express/lib/response.js:278:15)
    at /opt/node_app/lib/server.js:81:29
    at Layer.handle_error (/opt/node_app/node_modules/express/lib/router/layer.js:71:5)
    at trim_prefix (/opt/node_app/node_modules/express/lib/router/index.js:326:13)
    at /opt/node_app/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/opt/node_app/node_modules/express/lib/router/index.js:346:12)

How then to design handle when 404 error appears?

Community Page
Last updated: