Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

"URL is not a constructor" #10

Closed
clxrityy opened this issue May 11, 2023 · 3 comments
Closed

"URL is not a constructor" #10

clxrityy opened this issue May 11, 2023 · 3 comments

Comments

@clxrityy
Copy link

quick-coc-wrapper: 1.0.3
centra: ^2.4.2


Error

Error message

"URL is not a constructor"

Full error

TypeError: URL is not a constructor
    at new CentraRequest (webpack-internal:///(:3000/app-client)/./node_modules/centra/model/CentraRequest.js:15:40)
    at module.exports [as default] (webpack-internal:///(:3000/app-client)/./node_modules/centra/createRequest.js:4:9)
    at eval (webpack-internal:///(:3000/app-client)/./node_modules/quick-coc-wrapper/dist/ClashAPI.js:50:41)
    at new Promise (<anonymous>)
    at ClashAPI.get (webpack-internal:///(:3000/app-client)/./node_modules/quick-coc-wrapper/dist/ClashAPI.js:32:16)
    at eval (webpack-internal:///(:3000/app-client)/./node_modules/quick-coc-wrapper/dist/ClashAPI.js:154:18)
    at new Promise (<anonymous>)
    at ClashAPI.fetchPlayer (webpack-internal:///(:3000/app-client)/./node_modules/quick-coc-wrapper/dist/ClashAPI.js:153:16)
    at query (webpack-internal:///(:3000/app-client)/./src/lib/queryApi.ts:24:71)
    at eval (webpack-internal:///(:3000/app-client)/./src/components/SearchResults.tsx:16:76)
    at commitHookEffectListMount (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:19974:23)
    at commitHookPassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22022:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22127:11)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22124:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22124:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22124:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22124:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22238:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)
    at commitPassiveMountOnFiber (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22124:9)
    at recursivelyTraversePassiveMountEffects (webpack-internal:///(:3000/app-client)/./node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js:22105:7)

Code

cocApi.ts

import { ClashAPI } from "quick-coc-wrapper";

const cocApi = new ClashAPI(process.env.COC_API_TOKEN as string);

export { cocApi };

queryApi.ts

import { cocApi } from "./cocApi";

const query = async (search: string) => {

    const list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

    function sleep(ms: number) {
        return new Promise((resolve) => setTimeout(resolve, ms))
    };

    for (const item in list) {
        const res = await cocApi.fetchPlayer(search)
            .then((res) => res.name)
            .catch((err) => console.log(err)
                // `(Error: ${err.message})`
        );

        await sleep(500);

        return res;
    }
};

export { query };
@Puyodead1
Copy link
Owner

I can't reproduce this, what nodejs version are you using?

@clxrityy
Copy link
Author

I can't reproduce this, what nodejs version are you using?

20.1.2 and I'm using Nextjs.

Here's the repo: https://github.com/clxrityy/clashstash

@Puyodead1
Copy link
Owner

Ah, this appears to be an issue with webpack/browserify.
ethanent/centra#6
ethanent/centra#10

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants