axios Request path contains unescaped characters
nodejsThe “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 = 'https://example.com/path 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 = `https://example.com/path?${queryString}`;
In this example, the qs.stringify() function will properly encode the parameters and build a correctly formatted query string.
Other Article on Tag nodejs
- - axios Request path contains unescaped characters
- - CryptoJS.HmacSHA256 Cannot read properties of undefined (reading 'sigBytes')
- - encrypt by java and decrypt by node
- - fetch function mode sors, no-cors, same-origin
- - How to set value for NODE_TLS_REJECT_UNAUTHORIZED
- - it error Request path contains unescaped characters
- - java vs nodejs
- - nodejs add redis
- - nodejs call api get request
- - nodejs connect mysql database