axios Request path contains unescaped characters


The “Request path contains unescaped characters” error typically occurs when there are special characters in the URL that have not been properly encoded or escaped. These special characters may include spaces, ampersands, and other characters that have a special meaning in a URL.

To resolve this error, you can try encoding the special characters using the percent-encoding format. In JavaScript, you can use the encodeURIComponent() function to encode the special characters in the URL. For example, if you have a URL with spaces in it, you can encode it as follows:

const url = ' with spaces';
const encodedUrl = encodeURIComponent(url);

This will encode the spaces in the URL as “%20”, which is the correct format for a URL.

Alternatively, you can try using a library like qs or query-string to build your query string parameters. These libraries will handle the encoding for you.

import qs from 'qs';

const params = {
  foo: 'bar',
  baz: 'qux'

const queryString = qs.stringify(params);
const url = `${queryString}`;

In this example, the qs.stringify() function will properly encode the parameters and build a correctly formatted query string.