JarvusInnovations / jarvus-postgrest-apikit

MIT License
5 stars 3 forks source link

Fetch remote fields does not parse JSON from responseText #1

Open timwis opened 9 years ago

timwis commented 9 years ago

If you specify fetchRemoteFields in your model, the response includes a non-parsed responseText object that needs to be parsed into response.data in order to access its columns

I resolved this using

response.data = Ext.decode(response.responseText, true);

But you'd probably want to perform a check of some sort before doing that (did the request work, is it actually json, etc.)

themightychris commented 9 years ago

Hmmm, the request() wrapper in the underlying jarvus-apikit package should be taking care of this: https://github.com/JarvusInnovations/jarvus-apikit/blob/master/src/util/AbstractAPI.js#L85

A suffixed content-type might deter it though

timwis commented 9 years ago

response.getResponseHeader('Content-Type') is undefined for some reason, even though the HTTP response clearly provides a content type of application/json

themightychris commented 9 years ago

Maybe the API for reading headers changed in extjs6 On Aug 9, 2015 3:12 PM, "Tim Wisniewski" notifications@github.com wrote:

response.getResponseHeader('Content-Type') is undefined for some reason, even though the HTTP response clearly provides a content type of application/json

— Reply to this email directly or view it on GitHub https://github.com/JarvusInnovations/jarvus-postgrest-apikit/issues/1#issuecomment-129226920 .

timwis commented 9 years ago

Weird, it looks like the server isn't returning the Content-type response header when done via Ext.js, but when I do it in a REST client it does return them

screen shot 2015-08-16 at 14 35 44
timwis commented 9 years ago

Nevermind, that's the pre-flight OPTIONS request. The actual OPTIONS request that follows does include Content-Type: application/json in the response headers. Perhaps Ext.js is getting the responses mixed up?