portable-cto / airtable-proxy-worker

A Cloudflare Worker that allows you to make secure requests to the Airtable API from your frontend.
135 stars 16 forks source link

GET request not listing in order #8

Closed ChonkyWonky closed 2 years ago

ChonkyWonky commented 2 years ago

I currently have a cloudflare worker running and sucessfully making GET requests from the airtable api to a website I am developing for a client. However, for some reason no matter what I do I can't get the worker to list the data from airtable in order (as it is in the table).

Here is the config for the request:

access-control-allow-headers: authorization,content-length,content-type,user-agent,x-airtable-application-id,x-airtable-user-agent,x-api-version,x-requested-with access-control-allow-methods: DELETE,GET,OPTIONS,PATCH,POST,PUT access-control-allow-origin: * airtable-uncompressed-content-length: 4538 cache-control: max-age=0 content-length: 4538 content-type: application/json; charset=utf-8 date: Tue, 01 Feb 2022 22:06:57 GMT server: Tengine set-cookie: brw=brwJu77SKzdnETPFC; path=/; expires=Wed, 01 Feb 2023 22:06:57 GMT; domain=.airtable.com; samesite=none; secure strict-transport-security: max-age=31536000; includeSubDomains; preload vary: Accept-Encoding x-content-type-options: nosniff x-frame-options: DENY

Here is a segment of the response (two entries):

{"records":[{"id":"recXXXXXXXXXXXXX","fields":{"Title":"No. 2","Art":[{"id":"attXXXXXXXXXXXXXXX","width":1538,"height":1889,"url":"(linktoartwork)","filename":"2022-02-01 13.50.38.jpg","size":1013607,"type":"image/jpeg","thumbnails":{"small":{"url":"(linktoartwork)","width":29,"height":36},"large":{"url":"(linktoartwork)","width":512,"height":629},"full":{"url":"(linktoartwork)","width":3000,"height":3000}}}],"ArtLink":"(linktoartwork)","ID":"2","Descriptor":"‘Beautiful ridicule’"},"createdTime":"2021-11-01T19:43:47.000Z"},{"id":"recXXXXXXXXXXXXX","fields":{"Title":"No. 5","Art":[{"id":"attXXXXXXXXXXXXXXX","width":1424,"height":2000,"url":"(linktoartwork)","filename":"2022-02-01 13.51.30.jpg","size":879128,"type":"image/jpeg","thumbnails":{"small":{"url":"(linktoartwork)","width":26,"height":36},"large":{"url":"(linktoartwork)","width":512,"height":719},"full":{"url":"(linktoartwork)","width":3000,"height":3000}}}],"ArtLink":"(linktoartwork)","ID":"5","Descriptor":"‘Mark David’"},"createdTime":"2021-11-01T19:43:47.000Z"}

Here is an image preview of how the response is displayed on the site:

firefox_5M4iNeBrn7

On the actual database it is in increasing order (No. 1, No.2, etc..) and that is how it should be listing. I was originally using nocodeapi which does just this, but it has a rate limit. This is much better suited for how much control Id like with my API, but I need it to list properly.

One last thing to mention is that I have tried rearranging the order in airtable and the output is the same. I'm thinking the issue has something to do with load time/cache.

karllhughes commented 2 years ago

@ChonkyWonky what's the URL of the get request look like?

And, is it working when you remove the proxy?

ChonkyWonky commented 2 years ago

Okay I just tried without the proxy, purely through the airtable API and it did the same thing. It is only listing properly through nocodeapi.

The get URL of the request looks like this: https://api.(domainname)/Gallery << using a subdomain route instead of the default cloudflare worker one but the problem still occurs regardless.

karllhughes commented 2 years ago

Ah, so maybe it's a bug in the Airtable API?

The Airtable forums might be a good place to ask about this.

ChonkyWonky commented 2 years ago

Yeah it was a filtering issue with the GET request, thanks.