Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: PiNetwork is not a constructor #9

Open
bailaoshijiadao opened this issue Oct 13, 2023 · 2 comments
Open

TypeError: PiNetwork is not a constructor #9

bailaoshijiadao opened this issue Oct 13, 2023 · 2 comments

Comments

@bailaoshijiadao
Copy link

file:///D:/github/2345pi-app-nav/server.js:23const
pi = new PiNetwork(apiKey, walletPrivateSeed)
TypeError: PiNetwork is not a constructorat
file:///D:/github/2345pi-app-nav/server.js:23:12at
ModuleTob.run (node:internal/modules/esm/module job:194:25)

Is this step an error due to my environment?

The environment of this project
https://github.com/pi-apps/2345pi-app-nav

@Chidiebere95
Copy link

I think it's because pi-backend (for nodejs) is not fully supported yet. You can try running it on ruby

@xsuve
Copy link

xsuve commented Mar 6, 2025

I don't think we should use it like this, but I was able to do something like this (until it gets fixed):

import PiNetwork from "pi-backend";

const pi = new PiNetwork.default(
    process.env.PI_API_KEY,
    process.env.PI_WALLET_SEED
);

Note that I used the .default() function/constructor of the entire PiNetwork object to construct the pi object.
Then the pi object can be used normally to call the other methods:

const paymentId = await pi.createPayment({ ... });
...

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

No branches or pull requests

3 participants