lagomFetch - a library to abstract out http requests

We at 55 Degrees built a small client side library that we call lagom-fetch.

It started out as an abstraction layer between AP.request and AJS.$.ajax but grew into a way for us to abstract out the development process from being dependent on the Atlassian Connect framework. We added functionality to it that allows us to register mock http requests in a storybook (and other) environments. For the apps where we are very client side heavy it means no more developing in the Connect iframe. :slight_smile:

We can in our mock area do:

PayloadRegister.enable(true);
PayloadRegister.registerPayload('GET','/rest/api/2/search?jql=project%3DOTHER&maxResults=0',null, {
   "startAt": 0,
   "maxResults": 0,
   "total": 13,
   "issues": []
  })

Then when we use lagomFetch to perform a search with the jql of project=OTHER with:

lagomFetch('GET','/rest/api/3/search?jql='+encodeURIComponent('project=OTHER')+'&maxResults=0)

we get back a promise with the json response object (or error). In a non-test environment (where you haven’t enabled the PayloadRegister) the appropriate AP.request or AJS.$.ajax is called instead.

We are currently working on open sourcing our monitoring utility that goes along with this (once we’ve run it through it’s paces) which allows us to replay the payloads back against a “known sane Jira instance”. We’re dogfooding that right now but are aiming to to share that with the community as well.

lagomFetch is out on npm and on Bitbucket at https://bitbucket.org/55degrees/lagom-fetch/src/master/ . If anything - I hope it will help somebody speed up their development process.

Huge kudos to @satvik at EasyAgile for helping to clean up our callback on lagomFetch :slight_smile:

11 Likes

Amazing, thanks for sharing @danielwester :heart: