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

Achievements fail #8

Closed codemaster closed 11 years ago

codemaster commented 11 years ago

Attempting to poll achievement, characterAchievements, or guildAchievements all fail:

[Error: When in doubt, blow it up. (page not found)] {"status":"nok","reason":"When in doubt, blow it up. (page not found)"}

codemaster commented 11 years ago

Double-checked that I am using armory v0.6.1 installed straight from npm

xtian commented 11 years ago

Hm, I can't reproduce this.

~/Projects/node-armory (master)$ node
> var a = require('./')
> a.guildAchievements({ region: 'us' }, function(err, res) { console.log(res[1]) })

> { id: 15077,
  achievements:
   [ { id: 5421,
   ...

> a.characterAchievements({ region: 'us' }, function(err, res) { console.log(res[0]) })

> { id: 92,
  achievements:
   [ { id: 6,
   ...
codemaster commented 11 years ago

I am trying with the first parameter being the following object: {"name":"Dargonaut","realm":"Shadowmoon","region":"us"}

still produces {"status":"nok","reason":"When in doubt, blow it up. (page not found)"}

xtian commented 11 years ago

Oh, sorry. The guildAchievements and characterAchievements methods correspond to data endpoints.

They provide a list of all possible achievements for guilds or characters. Check out the Blizzard API docs for more info.

What you want is:

var armory = require('armory')

var options =
{ name: 'Dargonaut'
, realm: 'Shadowmoon'
, region: 'us'
, fields: ['achievements']
}

armory.character(options, function(err, character) {
  if (err) { return }

  console.log(character.achievements)
})

That'll give you an object with this structure: https://gist.github.com/Peratryn/3772776/raw/character-achievements.json

My docs and/or API should probably be clearer about that distinction.

codemaster commented 11 years ago

A-ha! Thank you :D

xtian commented 11 years ago

No problem!