In the above getGallery code we notice a few things. Notice that we are creating default values for each parameter of the Gallery endpoint to prevent any errors. When we make the $http request we return the result as a promise. If the promise is successful, a Gallery Image or Gallery Album is returned, otherwise the error the server provides is returned.

The ng-imgur library is not complete. There are many API endpoints which I’ve not had time to add. Many have already been implemented, but based on the knowledge you’ve just learned, many of the missing functions can be easily added.

Conclusion

Creating and using an AngularJS factory for Imgur is not difficult. Because the Imgur RESTful API is large and thorough, the ng-imgur library I made is not complete with all the endpoints, but it is getting there. I encourage everyone to fork the repository and contribute any functions that are missing.

Nic Raboy

Nic Raboy is an advocate of modern web and mobile development technologies. He has experience in Java, JavaScript, Golang and a variety of frameworks such as Angular, NativeScript, and Apache Cordova. Nic writes about his development experiences related to making web and mobile development easier to understand.