Build a Fetch Wrapper with Pluggable Request and Response Interceptors

Create a custom HTTP client (similar to Axios interceptors) that wraps the native fetch API and allows registering request interceptors (to modify headers, inject auth tokens, log outgoing requests) and response interceptors (to parse responses, handle global errors like 401/500, or retry on failure). Interceptors should be chainable and composable. This is directly how Axios works internally and is asked at every company using custom API layers.

Examples
Input: []
Output:
Hints

Build a Fetch Wrapper with Pluggable Request and Response Interceptors

Create a custom HTTP client (similar to Axios interceptors) that wraps the native fetch API and allows registering request interceptors (to modify headers, inject auth tokens, log outgoing requests) and response interceptors (to parse responses, handle global errors like 401/500, or retry on failure). Interceptors should be chainable and composable. This is directly how Axios works internally and is asked at every company using custom API layers.