zooniverse / front-end-monorepo

A rebuild of the front-end for zooniverse.org
https://www.zooniverse.org
Apache License 2.0
104 stars 29 forks source link

Create interface to abstract away API interactions #18

Closed rogerhutchings closed 5 years ago

rogerhutchings commented 6 years ago

From @rogerhutchings on December 5, 2017 15:46

Copied from original issue: zooniverse/panoptesjs#1

rogerhutchings commented 6 years ago

From @srallen on February 9, 2018 18:21

I'd like to avoid the high level of abstraction the current json-api-client does. The simple abstraction I did in edu-api-front-end is more the direction I'd like. I also did the same in my example react, router5, mobx app: https://github.com/srallen/react-mobx-starter/blob/master/app/lib/apiClient.js

We could have a mobx store handle auth and some simple functions to add anything we would like on top of superagent. Another similar approach that we could borrow is in this mobx real world example app which also has defined the class methods for requests per model: https://github.com/gothinkster/react-mobx-realworld-example-app/blob/master/src/agent.js

srallen commented 5 years ago

panoptes.js has request helpers per model (still being built out) as well as a simple set for basic HTTP REST.