The key to answering this is to make sure you clearly understand what you’re getting back. As you have deduced, a good way to do this is to console.log
the results. However, on its own console.log
is very helpful. Here’s what I did to understand what is going on (and the result is maybe not quite what you thought). Note the use of JSON.stringify
to get a more helpful log.
in server/main.js
import { Meteor } from 'meteor/meteor';
import { xml2js } from 'meteor/peerlibrary:xml2js';
Meteor.startup(() => {
try {
const response = HTTP.get("http://api.eve-central.com/api/marketstat?typeid=29668®ionlimit=10000002&hours=12");
const result = xml2js.parseStringSync(response.content);
console.log(JSON.stringify(result,null,2));
} catch (error) {
console.log(error);
}
});
As you will see, this is not in a method and no client code is needed. Starting meteor results in this:
{
"evec_api": {
"$": {
"version": "2.0",
"method": "marketstat_xml"
},
"marketstat": [
{
"type": [
{
"$": {
"id": "29668"
},
"buy": [
{
"volume": [
"1235"
],
"avg": [
"862555051.24"
],
"max": [
"1047800000.00"
],
"min": [
"1999995.99"
],
"stddev": [
"435301531.53"
],
"median": [
"1013300001.00"
],
"percentile": [
"1046890915.49"
]
}
],
"sell": [
{
"volume": [
"2692"
],
"avg": [
"1225511768.79"
],
"max": [
"2010000000.00"
],
"min": [
"1047800000.00"
],
"stddev": [
"125954124.78"
],
"median": [
"1225500000.00"
],
"percentile": [
"1051382202.56"
]
}
],
"all": [
{
"volume": [
"223854"
],
"avg": [
"8654.89"
],
"max": [
"16597485.32"
],
"min": [
"0.30"
],
"stddev": [
"3634873.14"
],
"median": [
"1.99"
],
"percentile": [
"1.00"
]
}
]
}
]
}
]
}
}
Hopefully, that will point you in the right direction to a solution, but if not, please shout up!