Citestore Plugin

Can you clarify something for me, still? I’m looking at the code in discourse-canned-replies and some other places. For example, the following:

return ajax("/posts/" + (this.get('id')) + "/recover", { type: 'PUT', cache: false }).then(function(data){
  .... // Do stuff
  });
}).catch(function(error) {
  .... // Do stuff
});

So, if I understood correctly, the format is the following, right?

ajax(route, data).then( function(data) { do your stuff } ).catch( function (error) { ... } )

The first message implied that that the format would be something more:

ajax(route, function(data) { do your stuff } );

Or are these the same thing?


Another question: The parameter data that is given after, if it’s JSON, can I use it out of the box? I mean, I have this in plugin.rb:

record = Citestore::Storage.get(user_id, handle, locus)
render json: record

It should be string. So is the data parameter (variable?) a string as well, or do I need to transform it somehow?