Describe the bug
When I run this code i got this error:
Code run:
const wordpressClient = new WordpressClient();
const posts = await wordpressClient.post().find()
With the following class, and wordpress is running on localhost:80
export class WordpressClient extends WpApiClient{
constructor() {
super("http://localhost");
}
post<P = WPPost<WordpressPost>>(): DefaultEndpointWithRevision<P> {
return super.post<P>()
}
}
Uncaught (in promise) TypeError: url_1.URLSearchParams is not a constructor
at WordpressClient.createEndpointGet (wp-api-client.js:40:48)
at WordpressClient.defaultEndpoints (wp-api-client.js:103:24)
at WordpressClient.addPostType (wp-api-client.js:112:21)
at WordpressClient.post (wp-api-client.js:181:21)
at WordpressClient.post (WorpressClient.ts:10:22)
at loadPosts (useWordpressData.ts:15:45)
at useWordpressData.ts:44:9
at commitHookEffectListMount (react-dom.development.js:23150:26)
at commitPassiveMountOnFiber (react-dom.development.js:24926:13)
at commitPassiveMountEffects_complete (react-dom.development.js:24891:9)
To Reproduce
Steps to reproduce the behavior:
- Run this code:
const posts = await wordpressClient.post().find()
Expected behavior
Expected to load data
Desktop (please complete the following information):
Builder:
Suggested change
I got it locally fixed by removing
import { URLSearchParams } from 'url'
Describe the bug
When I run this code i got this error:
Code run:
With the following class, and wordpress is running on localhost:80
Uncaught (in promise) TypeError: url_1.URLSearchParams is not a constructor at WordpressClient.createEndpointGet (wp-api-client.js:40:48) at WordpressClient.defaultEndpoints (wp-api-client.js:103:24) at WordpressClient.addPostType (wp-api-client.js:112:21) at WordpressClient.post (wp-api-client.js:181:21) at WordpressClient.post (WorpressClient.ts:10:22) at loadPosts (useWordpressData.ts:15:45) at useWordpressData.ts:44:9 at commitHookEffectListMount (react-dom.development.js:23150:26) at commitPassiveMountOnFiber (react-dom.development.js:24926:13) at commitPassiveMountEffects_complete (react-dom.development.js:24891:9)To Reproduce
Steps to reproduce the behavior:
Expected behavior
Expected to load data
Desktop (please complete the following information):
Builder:
Suggested change
I got it locally fixed by removing