WFCD / warframe-worldstate-parser

:green_book: An Open parser for Warframe's Worldstate in Javascript
https://wfcd.github.io/warframe-worldstate-parser/
MIT License
54 stars 18 forks source link

Error whilst running Usage code provided by README #34

Closed ghost closed 8 years ago

ghost commented 8 years ago

Tried to test how it works (since there isn't much to read about) by running the code provided by the README

var WorldState = require('warframe-worldstate-parser');
var worldStates = {
  PC : new Worldstate('PC'),
  PS4 : new Worldstate('PS4'),
  X1 : new Worldstate('X1'),
}
var primeAccess = null;
worldStates[PC].getPrimeAccessString(function(err, primeAccessObject) {
  if (err) {
    return console.err(err);
  }
  primeAccess = primeAccessObject;
});

Sadly after running it I got the following error

ReferenceError: Worldstate is not defined
    at Object.<anonymous> (removedForObviousReasons\test.js:3:12)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

I'm sorry if I misunderstood something of the code that is provided.

EDIT: Grammar and markup fix

TobiTenno commented 8 years ago

It's definitely a typo in the test code. From the JSON and attempt to call:

- Worldstate

From the require:

+ WorldState
TobiTenno commented 8 years ago

Capitalization win.

TobiTenno commented 8 years ago

Feel free to contact me on Discord if you'd like, and you use the application. My id is Tobiah#8452

ghost commented 8 years ago

I ran the preview code again, following the steps you said it still gave me the same error, so I tried the following:

var Worldstate = require('warframe-worldstate-parser');
var worldStates = {
  PC : new WorldState('PC'),
  PS4 : new WorldState('PS4'),
  X1 : new WorldState('X1'),
}
var primeAccess = null;
worldStates[PC].getPrimeAccessString(function(err, primeAccessObject) {
  if (err) {
    return console.err(err);
  }
  primeAccess = primeAccessObject;
});

This resulted in the following error:

hidden for obvious reasons\node_modules\warframe-worldstate-parser\src\modules\news.js:14
  for (var index = 0; index < data.length; index++){
                                  ^

TypeError: Cannot read property 'length' of undefined
    at new News (hidden for obvious reasons\node_modules\warframe-worldstate-parser\src\modules\news.js:14:35)
    at new WorldState (hidden for obvious reasons\node_modules\warframe-worldstate-parser\src\worldstate.js:23:15)
    at Object.<anonymous> (hidden for obvious reasons\try.js:3:8)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

Hope this helps

EDIT: Grammar fixes

TobiTenno commented 8 years ago

doesn't particularly help at all.

TobiTenno commented 8 years ago

Are you allowing node access to the internet?

ghost commented 8 years ago

Node has internet access, I tried both the github master branch and the npm version Both seem to give the exact same error

I even tried to run it on RunKit, and got the same errors Using the following code

require("warframe-worldstate-data");
require("warframe-worldstate-parser");
var worldStates = {
  PC : new WorldState('PC'),
  PS4 : new WorldState('PS4'),
  X1 : new WorldState('X1'),
}
var primeAccess = null;
worldStates[platform].getPrimeAccessString(function(err, primeAccessObject) {
  if (err) {
    return console.err(err);
  }
  primeAccess = primeAccessObject;
});

With and without caps WorldState. Just to make sure that I didn't experience a bad install of some sorts.

One thing to note tho: whilst running the code on RunKit without require 'warframe-worldstate-data' it gave me the following error Cannot find module 'warframe-worldstate-data' . Hope this provided you with enough info to fix the problem.

EDIT: added RunKit info

TobiTenno commented 8 years ago

on the data module, you have to install it separately if you're going to use it in that manner because parser pulls it in on its own. In addition, it doesn't look like you're setting the result of the require to anything, which is why you can't access any of it's properties.

where you do primeAccess = primeAccessObject;

change it to

console.log(primeAccessObject); just to see what you get if the code ever reaches there.

TobiTenno commented 8 years ago

RunKit probably doesn't pull in the transitive dependencies correctly, would be my guess.

ghost commented 8 years ago

Your suggestion still gave me the same error regarding news.js, So I tried to comment every inclusion of news.js and ran it but this time it gave me an error of sorties.js. Both news.js and worldstate.js run perfectly fine alone, but if I try to call them via the readme example it just gives the usual error of undefined .length

TobiTenno commented 8 years ago

Sorry I haven't helped you in so long. Have you been able to figure anything out?

ghost commented 8 years ago

Havn't been able to figure anything new out. Only thing to note is that when I comment out sortie.js it then continous to give me an error of the next require which in this case is globalModifiers.js. The error usually contains an undefined length of the data array. I will try to uninstall and reinstall the package to see if the problem reoccurs.

EDIT: Reinstalling didn't fix anything it resulted in the same old error. I'll try c9 just to make sure it isn't the pc I'm using itself. Could you try to install it in a different folder and run the sample code? Then we could hopefully obtain more information regarding the error. C9 resulted in the same error.

TobiTenno commented 8 years ago

Just so you know, I haven't forgotten, I'm looking into it still and working on reproducing your error.

Feel free to hit me up on Discord, if you have the time.

TobiTenno commented 8 years ago

@Cp-022 I got it figured out. I'm updating the sample doc, because this was totally a flub on my part.

ghost commented 8 years ago

Got it working, thanks for the patience!

TobiTenno commented 8 years ago

No problem, I'm sorry it took me so long to find that.