mercredi 19 octobre 2016

Ember first application wont recognize xmlcode inside xml2json

Sorry if this problem could be because my lack of knowledge in node/npm area.

I created my first ember webapplication

I install xml2json with npn and bower and added

app.import('node_module/xml2json/xml2json.js') 

in ember_build_cli.js before return app.toTree();

I added custom route via generate and added a function that should read xml, convert it to json and output data

import Ember from 'ember';
export default Ember.Route.extend({
model() {
  return Ember.$.ajax({
   url: "http://ift.tt/2dAIOiK",
    dataType:"xml"
  }).done(function(xmlData){
      var jsonData = xml2json.xml_to_object(xmlData);
//      console.dir(jsonData);
//      console.log(JSON.stringify(jsonData));
      return jsonData;
 });
}
});

I have a problem that xml2json dont work. As I was able to install Ember Inspector inside Firefox I end up with this error:

TypeError: xmlcode.replace is not a function

As I understand the xml2json is imported correctly but Ember/Firefox don't understand code xmlcode.replace inside xml2json library.

Did I miss something when installing application or im doing something wrong?




Aucun commentaire:

Enregistrer un commentaire