Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Removed class instance for a pure function.
Browse files Browse the repository at this point in the history
  • Loading branch information
hmschreiner committed May 28, 2017
1 parent 9fa89e6 commit aa23c1f
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions src/endpoints/blog.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
import errorHandler from '../helpers/errorHandler'

class Blog {
const Blog = (api = null) => {

constructor(api = null) {
if (api === null) throw new Error('Request instance must be provided on constructor.')

if (api === null) throw new Error('Request instance must be provided on constructor.')
return {
getAllBlogs(params) {

this.api = api
}

getAllBlogs(params) {

return this.api.get('content/api/v2/blogs', { ...params })
.then(response => response)
.catch(error => errorHandler(error))
}

getPosts(params) {

return this.api.get('content/api/v2/blog-posts', { ...params })
.then(response => response)
.catch(error => errorHandler(error))
}
return api.get('content/api/v2/blogs', { ...params })
.then(response => response)
.catch(error => errorHandler(error))
},
getPosts(params) {

getPostById(postId) {
return api.get('content/api/v2/blog-posts', { ...params })
.then(response => response)
.catch(error => errorHandler(error))
},
getPostById(postId) {

return this.api.get(`content/api/v2/blog-posts/${postId}`)
.then(response => response)
.catch(error => errorHandler(error))
return api.get(`content/api/v2/blog-posts/${postId}`)
.then(response => response)
.catch(error => errorHandler(error))
},
}
}

Expand Down

0 comments on commit aa23c1f

Please sign in to comment.