Solved: Possible Unhandled Promise Rejection (id: 0): Error: URL.search is not implemented.
1 min read

Solved: Possible Unhandled Promise Rejection (id: 0): Error: URL.search is not implemented.

Solved: Possible Unhandled Promise Rejection (id: 0):
Error: URL.search is not implemented.

The Problem

This error came up while I was developing a React Native application and tried using Axios and an API client I generated using OpenAPI Generator (and with typescript settings).

React Native isn't compliant with WHATWG URL standard, which causes this error to popup.

The Solution

You need to install a package to polyfill the API client.

yarn add react-native-url-polyfill

After adding the package you also need to import the polyfill on the first line within your generated API client (or other file that is causing this error).
You can import the polyfill using:

import 'react-native-url-polyfill/auto';