This will be required for farmOS/farmOS-client#353. I considered just doing this manually from within Field Kit, but talking with @paul121 I realized it's still complicated enough—handing the OAuth tokens, adding them to the headers, refreshing them if necessary, error handling, etc—that it's just better to build it into farmOS.js.
Some consideration to the API: it'd be nice to accept parameters to only fetch an area type, such as fields, beds, etc. That'd be simple enough by appending it to the endpoint, but I don't need it for my immediate use case. I need all the areas, which is what you get when you append nothing to the main endpoint, so I'm not going to deal with any parameters now. Just do farm.area.geojson(), that's it. That should make it possible to add an options parameter in the future.
This will be required for farmOS/farmOS-client#353. I considered just doing this manually from within Field Kit, but talking with @paul121 I realized it's still complicated enough—handing the OAuth tokens, adding them to the headers, refreshing them if necessary, error handling, etc—that it's just better to build it into farmOS.js.
Some consideration to the API: it'd be nice to accept parameters to only fetch an area type, such as fields, beds, etc. That'd be simple enough by appending it to the endpoint, but I don't need it for my immediate use case. I need all the areas, which is what you get when you append nothing to the main endpoint, so I'm not going to deal with any parameters now. Just do
farm.area.geojson()
, that's it. That should make it possible to add an options parameter in the future.