danielwerg/r6api.js

Example Code Not Working

Closed this issue · 5 comments

I tried to use the example code and I put my email and password in a .env file and I didn't get any output

Well, sounds like you didn't console.log anything, because you should get Daniel.Nt has played 6278 matches. output from example code.

How nice of you to assume the I didn't do something that I did

How nice of you to assume the I didn't do something that I did

All you can do is assume when you have one sentence in an issue with no way to reproduce it.

All you can do is assume when you have one sentence in an issue with no way to reproduce it.

Even when I console log I don't get anything it only allows me to console log something like "hi" outside of the example code

example.js
require('dotenv').config();
const R6API = require('r6api.js').default;

const { UBI_EMAIL: email = '', UBI_PASSWORD: password = '' } = process.env;
const r6api = new R6API({ email, password });

(async () => {

  const username = 'Daniel.Nt';
  const platform = 'uplay';

  const { 0: player } = await r6api.findByUsername(platform, username);
  if (!player) return 'Player not found';

  const { 0: stats } = await r6api.getStats(platform, player.id);
  if (!stats) return 'Stats not found';
  const { pvp: { general } } = stats;

  console.log(`${player.username} has played ${general.matches} matches.`);

})();

prints: Daniel.Nt has played 6278 matches.

https://nodejs.org/api/modules.html