-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observe API service #119
Observe API service #119
Conversation
@batpad, developmentseed/observe-dashboard#16 has a working implementation of async actions based the framework conceived by Daniel. It also includes a wrapper function to make authenticated requests seamlessly and a basic example on how to read data and handle errors. |
…rror handling to base callAPI function
9310ec5
to
4977533
Compare
Have wired up the I'll add some tests for different status responses from the API. Let me know if there are thoughts / questions on the code so far, @geohacker @vgeorge @sethvincent . TODO:
|
@batpad I pushed a commit with some small changes needed to get things running. I can login fine. It seems like I'm getting errors sending photos to the api:
Not sure yet if this is an api problem or an app problem. I can follow up with more debugging tomorrow. |
@sethvincent oops sorry I wasn't more clear -- this PR only includes the actions to POST Traces. If the structure looks okay and that works, I thought I'd work on photos in a separate PR. |
@sethvincent thanks for the catch on persisting the token. |
@batpad oh ok that makes sense. I'll take another quick look. I feel like what's here is pretty great. |
I'm getting an error when posting to observe-api:
I think because |
app/reducers/traces.js
Outdated
traces[index].pending = false | ||
traces[index].uploading = false | ||
traces[index].id = action.newId | ||
if (!traces[index].properties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original idea was not correct. The error I was seeing was because the properties object doesn't exist sometimes when adding the id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm it seems a bit strange that the properties object would not exist - this maybe better to ensure a bit further up when the trace is being created. Let me look a bit closer. Thanks for the catch / fix.
I resolved the above error and it seems now that if a trace description is an empty string that i get an A higher-level issue I've noticed is that if the server restarts after making changes the next time I try to post a trace the app will crash and stay in that state until i delete it and reinstall. Presumably something similar would happen anytime the access token would expire? We may need to make an issue for this and tackle it in a follow-up pr if not in this one. |
This looks fixed by developmentseed/observe-api#32
I have made an issue for this here: #132 I'm a bit conflicted on whether to tackle this in this PR or as the next follow-up. I can't quite wrap my head around the cleanest way to handle token expiry, and also think it may need some UI pieces figured out. I'm going to hold off on merging this just yet though, because this is a pretty bad issue, and we should think this through. Thanks a lot for the fixes and review, @sethvincent . |
…eed/observe into feature/observe-api-service
… similar to edits
I added tests for the reducer, and also changed to using a single @geohacker - if this looks good, I think we can merge. And then I can start working on the API token expiry in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this on iOS and seemed to work well. I think we should test again after building the Your Traces screen. I got a promise rejection warning when I tried to 'Get Observe API profile' in the settings -- might be something minor but just noting.
…eed/observe into feature/observe-api-service
Service that actions can call to talk to the Observe API.
Currently, implements a base
callAPI
function that other API methods can call - handles setting the authorization header and passing parameters for GET and POST requests.Sets up a simple test to call the
getProfile
action that currently just console.logs the user profile information fetched from the API.Next steps:
cc @vgeorge @geohacker