# React Native fetch fails with Postman mock server: CORS, headers, and schema mismatches

**URL:** <https://community.postman.com/t/react-native-fetch-fails-with-postman-mock-server-cors-headers-and-schema-mismatches/83298>\
**Category:** Help Hub\
**Tags:** native\
**Created:** [August 5, 2025, 4:27pm UTC](https://community.postman.com/t/react-native-fetch-fails-with-postman-mock-server-cors-headers-and-schema-mismatches/83298 "2025-08-05T16:27:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yonandualem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yonandualem/32/33147_2.png) [@yonandualem](https://community.postman.com/u/yonandualem)\
**Post date:** [August 5, 2025, 4:27pm UTC](https://community.postman.com/t/react-native-fetch-fails-with-postman-mock-server-cors-headers-and-schema-mismatches/83298/1 "2025-08-05T16:27:29Z")

</div>

> **Archived topic — some details may be out of date.**  
> Mock servers built from saved collection examples are still supported. Postman now also has **code-based mocks** : JavaScript request handlers plus a `config.yaml`, stored as files in your Git repository, which you can run locally or deploy. Create one in the app, or use the Postman CLI to generate one from an OpenAPI spec, collection or dataset (`postman mock generate`) and run it (`postman mock run`). See [About mocks](https://learning.postman.com/docs/design-apis/mock-apis/mocks/overview) and [Create a mock](https://learning.postman.com/docs/design-apis/mock-apis/mocks/create-a-mock).  
> Working with an AI coding agent? The [Postman plugin](https://github.com/postmanlabs/postman-plugin) can build and run mocks for you.  
> For current help, see the [Postman docs](https://learning.postman.com/docs/), try the free [Postman tools](https://www.postman.com/tools) (no account needed), or join us on [Discord](https://discord.gg/58aNNsRBGR).

I’m using the latest Postman mock server with API versioning to develop against my evolving backend schema, but I keep hitting a wall. My fetch requests, which work fine against production, often fail with the mock server due to missing or inconsistent CORS and custom auth headers, and sometimes the mock returns JSON that doesn’t match my OpenAPI schema—fields are missing or the types are off, even when the schema is up to date. Switching API versions in Postman sometimes leaves stale responses or mismatches, and dynamic path parameters like `/user/:id/items` intermittently 404 or return partial data. Here’s a typical fetch that works in production but fails with the mock server:

```auto
fetch('https://mock-server-url/user/123/items', {
  method: 'GET',
  headers: {
    'Accept': 'application/json',
    'X-Auth-Token': 'mytoken'
  }
})
  .then(res => res.json())
  .then(data => console.log(data))
  .catch(err => console.error('API error:', err));

```

With the mock server, I get either `Network request failed` or `Unexpected token < in JSON at position 0` . Is there a way to guarantee the Postman mock server always returns the correct schema (with all fields and types), includes all CORS and custom headers so fetch requests don’t fail, keeps mock responses in sync across API versions, and reliably handles dynamic path params?

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [August 15, 2025, 10:46am UTC](https://community.postman.com/t/react-native-fetch-fails-with-postman-mock-server-cors-headers-and-schema-mismatches/83298/2 "2025-08-15T10:46:19Z")

</div>

Hi @yonandualem. Mock servers in Postman are tied to saved request examples and not your OpenAPI Schema. Could you share a bit more about what you mean by “Mock server with API versioning”?

---

<div class="post-metadata">

**Author:** ![yonandualem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/yonandualem/32/33147_2.png) [@yonandualem](https://community.postman.com/u/yonandualem)\
**Post date:** [August 28, 2025, 9:48am UTC](https://community.postman.com/t/react-native-fetch-fails-with-postman-mock-server-cors-headers-and-schema-mismatches/83298/3 "2025-08-28T09:48:46Z")

</div>

Never mind I have solved this issue. Thank you for your help!
