xtian / node-armory

A simple node.js wrapper around Blizzard's REST API for World of Warcraft.
MIT License
24 stars 8 forks source link

Options._Query Character Parameter For Query Fields #9

Closed khaccounts closed 9 years ago

khaccounts commented 10 years ago

Hey there.

I am new to Node, so I am sure that I am missing a step here and maybe you can help.

What I am trying to do is:

app.post('/api/character', function(req, res) {
    var armory = require('armory').defaults({
        name: req.body.characterName,
        realm: req.body.serverName,
        region: req.body.serverCountry,
        _query: 'stats,professions,titles,items,reputation,mounts,pets,achievements'
    })

    armory.character(function(err, character){
            console.log(character);
    })

    res.status(200).send('angular send off');
});

So, the '_query' should have all of the fields that I am trying to request from the Blizzard API for that specific character, but it is just empty when I console.log it in 'armory/index.js' file that you created.

What I am missing here to get your wrapper class to send off the fields to API to get back all of that data?

khaccounts commented 10 years ago

Nevermind. I figured it out. It is the use of the fields option.

So, if anyone else has a problem with this, it should look like this:

app.post('/api/character', function(req, res) {
    var armory = require('armory').defaults({
        name: req.body.characterName,
        realm: req.body.serverName,
        region: req.body.serverCountry,
        fields: ['stats,professions,titles,items,reputation,mounts,pets,achievements']
    })

    armory.character(function(err, character){
            console.log(character);
    })

    res.status(200).send('angular send off');
});

I would recommend that you update your ReadMe to include this, as the optional fields are a big deal in my opinion!

Thanks for writing this wrapper. Saved me a lot time trying to figure out how to build it!