fakeshadow / pxs-psn-api

a psn api wrapper
29 stars 10 forks source link

Error Message #13

Open darias08 opened 1 year ago

darias08 commented 1 year ago

Hello, I copied your index.js file and I am getting an error message saying that form-data-fork could not be found. Do I need to install a npm for that?

Here's the error message I am recieving:

form-data-fork could not be found within the project or in these directories: node_modules ......\node_modules 5 | const http = require('./http'); 6 | const fetch = require('node-fetch'); 7 | const formData = require('form-data-fork'); ^

fakeshadow commented 1 year ago

did you try npm install. as the package is still there. https://www.npmjs.com/package/form-data-fork

darias08 commented 1 year ago

Okay, so I am getting another error message saying that the fs is found, however this package itself specifies a main module field that could not be resolved. I have the main displayed in my app.js like this and imported the index.js as well.

Here's how I have it.

const PSN = require('../../components/services/psn');

// psn object accept optional params when construct.
const psn = new PSN({
    lang: "en",  //(default value en)
    region: "hk",  // server region(default value us)
    refresh_token: null, //refresh_token(default value null)
    access_token: null  //access_token(default value null)
});

const npsso = "nppso";

async function main() {
  try {
      await psn.auth(npsso);

      // access token is used to call other api, and refresh token is used to get new access_token when it's expired
      console.log(psn.access_token, psn.refresh_token);

      // get user profile with access_token
      const profile = await psn.getProfile("Kill_Zone_Joker");
      console.log(profile);

  } catch (e) {
      console.log('error: ', e);
  }
}

main();

export default App

Also is it necessary to add the main(); method at the end or it's not mandatory to have it there?