*** title: Route response data with TypeScript in Flows updated: 2025-09-20T00:00:00.000Z slug: docs/postman-flows/typescript/typescript-health-performance-routing max-toc-depth: 2 ---------------- This example uses three TypeScript expressions to route response data based on health and performance using a **Condition** block. The first expression to return `true` routes the response data through its output port. If none of the three TypeScript expressions resolve to true, the **Condition** block routes the response data through the **Default** output port. ## Example JSON The example uses JSON data from a GET request to `postman-echo.com` like this: ```json { "body": { "args": {}, "headers": { "host": "postman-echo.com", "x-request-start": "t1757972551.591", "connection": "close", "x-forwarded-proto": "https", "x-forwarded-port": "443", "x-amzn-trace-id": "Root=1-68c88847-aaaaaaaaaaaaaaaaaaaaaaaa", "user-agent": "PostmanRuntime/7.46.0", "accept": "*/*", "cache-control": "no-cache", "postman-token": "00000000-1111-2222-3333-444444444444", "accept-encoding": "gzip, deflate, br", "cookie": "sails.sid=s%3AdummySessionId1234567890.abcdef1234567890" }, "url": "https://postman-echo.com/get" }, "http": { "status": 200, "headers": { "Date": "Mon, 15 Sep 2025 21:42:31 GMT", "Content-Type": "application/json; charset=utf-8", "Content-Length": "621", "Connection": "keep-alive", "Server": "nginx", "ETag": "W/"26d-FAKEETAG1234567890"", "Set-Cookie": "sails.sid=s%3AdummySetCookieId0987654321.qwerty9876543210; Path=/; HttpOnly" } }, "tests": [], "binary": false } ``` ## Condition 1: Check for critical server errors The TypeScript in this condition finds the response's status code and checks if the code is greater than or equal to 400: ```javascript response.http.status >= 400 ``` ## Condition 2: Check for slow response The TypeScript in this condition finds the `Server-Timing` header value and checks if it's greater than 1000. The `Server-Timing` header shows the number of milliseconds the request took to process. If it's greater than 1000 ms, that could indicate a slow response. ```javascript Number((response.http.headers["Server-Timing"] || "") .match(/dur=([\d.]+)/)?.[1]) > 1000 ``` ## Condition 3: Not JSON The TypeScript in this condition checks if the `Content-Type` header is missing the string `application/json`. If `application/json` isn't present in the header, the expression returns true and routes the response from this condition's output port. If the string is present, the expression returns false. ```javascript !(response.http.headers["Content-Type"]?.includes("application/json")) ``` ## Example To see this TypeScript in an example flow, check out [TypeScript example 3: Response health and performance routing](https://www.postman.com/postman/flows-snippets/flow/68c9cb22d0954f00138d7ea9).