-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Comment Section #26
Conversation
Status: Required Changes ♻️Hi @ginabeki , Good job so far! Highlights
Required Changes ♻️Check the comments under the review. Optional suggestionsEvery comment with the [OPTIONAL] prefix is not crucial enough to stop the approval of this PR. However, I strongly recommend you to take them into account as they can make your code better. Cheers and Happy coding!👏👏👏 Feel free to leave any questions or comments in the PR thread if something is not 100% clear. Please, do not open a new Pull Request for re-reviews. You should use the same Pull Request submitted for the first review, either valid or invalid unless it is requested otherwise. As described in the Code reviews limits policy you have a limited number of reviews per project (check the exact number in your Dashboard). If you think that the code review was not fair, you can request a second opinion using this form. |
src/modules/api/Comment.js
Outdated
import axios from 'axios'; | ||
|
||
export default class Comments { | ||
constructor() { | ||
this.involvementApi = process.env.INVOLVEMENT_API_LINK; | ||
this.involvementApiId = process.env.INVOLVEMENT_ID; | ||
this.commentsEndPoint = `/apps/${this.involvementApiId}/comments`; | ||
this.commentsAllEndPoint = `/apps/${this.involvementApiId}/comments?item_id=`; | ||
} | ||
|
||
// eslint-disable-next-line consistent-return | ||
getComments = async (id) => { | ||
try { | ||
// eslint-disable-next-line consistent-return | ||
return await axios.get(`${this.involvementApi}${this.commentsAllEndPoint}${id}`).then((res) => { | ||
if (res.status === 200) { | ||
return res; | ||
} | ||
}); | ||
} catch (error) { | ||
if (error.response) { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
addComment = async (itemId, username, comment) => { | ||
try { | ||
// eslint-disable-next-line consistent-return | ||
return await axios.post(`${this.involvementApi}${this.commentsEndPoint}`, { | ||
item_id: itemId, | ||
username, | ||
comment, | ||
}).then((res) => { | ||
if (res.status === 201) { | ||
return true; | ||
} | ||
throw new Error('Fail'); | ||
}); | ||
} catch (error) { | ||
throw new Error('Fail'); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Kindly add descriptive comments to your code to make it readable. Proper use of commenting can make code maintenance much easier, as well as helping make finding bugs faster. Also, it will be very important when writing functions that other people will use.
In this milestone,
I added :