In my attempt to make an API call to a Wordpress REST API, I came across different ways of doing so. The console version of the call looks like this:
http://dev.thomastraum.com/wp-json/posts?type=tt_works&filter[work_categories]=all&filter[posts_per_page]=1
Using Meteor, a functional call appears as follows:
return Meteor.http.call("GET", Settings.wpdomain + "/wp-json/posts", {params: {'type':'tt_works','filter[work_categories]':'all','filter[posts_per_page]':'1'}});
My question now is, how can I correctly format JavaScript objects to be passed into the Meteor call? Initially, I thought they should be structured like this:
ArchiveQuery = {
type:'tt_works',
filter:{
work_categories:'all',
posts_per_page:1
}
};
However, when I pass it like this:
return Meteor.http.call("GET", Settings.wpdomain + "/wp-json/posts", {params:ArchiveQuery);
it only returns posts with the specific type and ignores the rest of the query. I attempted EJSON.stringify(ArchiveQuery)
, but it produced a different formatted query with curly braces {}
.