You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you externalize all dataservice endpoint/urls into a serviceURLs factory, you can inject this service map instead of injecting the flat ENDPOINT_URL constant. You could also configure your ENDPOINT_URL during config() time and update all urls in the serviceURLs instance before the service map is injected in other Services.
/** * URLS before prefixing with ENDPOINT * * var URLS = { * * STORY : { * FIND_ALL : "/clients/{1}/stories.json" * , LOAD_STORY : "/clients/{1}/stories/{2}.json" * } * USER : { * LOAD_ALL : "clients/{0}/users.json" * } * }; */// Register the StoryService with AngularJSmyModule.factory('storyService',['authService','serviceURLs','$http',StoryService]);functionStoryService(authService,serviceURLs,$http){// Published `promise-returning` APIreturn{findAllStories : findAllStories,loadStory : loadStory}// **********************************// Internal Methods// **********************************functionfindAllStories(){return$http.get(supplant(serviceURLs.STORY.FIND_ALL,[AuthService.getCurrentUserId()]));}functionloadStory(storyID){return$http.get(supplant(serviceURLs.STORY.LOAD_STORY,[AuthService.getCurrentUserId(),storyID]));}}
Your do not need to wrap
$http()
calls with$q.defer()
usages.And consolidate all URLs into a url map. Consider this result:
The text was updated successfully, but these errors were encountered: