How to get data object from json-ld response using Meteor.http.call?


#1

Hey

So I’m trying to use Meteor.http.call to get and store a json-ld response. However at the moment the data object in the result is null. The content string though is populated with the full response.

The docs suggest this is due to meteor not being able to understand that this is still a json file:

data Object or null
If the response headers indicate JSON content, this contains the body of the document parsed as a JSON object.

This is the header for the Content-Type I’m getting back:

Content-Type →application/ld+json;charset=UTF-8

Any way to make it handle json-ld correctly?


#2

As a workaround I’m parsing the content field with EJSON.parse();


#3

I have the same problem with maxmind response, it is stated in their response header:

content-type: "application/vnd.maxmind.com-city+json; charset=UTF-8; version=2.1"

which is not interpreted by HTTP.call as valid Json type… So I have to manually parse the content. Not a big deal, but it seem there is a bug HTTP.call?


#4

I’m not sure that RFC 6839 has been approved for +json. However, if it’s being widely used it may make sense to adopt it into Meteor.

It looks like a relatively small change to the http package:

Why not submit a PR?