Skip to content

Commit

Permalink
fix: vote type api issue fixed #634
Browse files Browse the repository at this point in the history
fixed issue
  • Loading branch information
jasurobo committed Dec 2, 2021
1 parent ab0bb6b commit 2fcad17
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
4 changes: 1 addition & 3 deletions component/layout/BlogPost/BlogPost.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export default function BlogPost(props) {
*/
//posts having no votes field will have null as initial state for voteType and votes are created during createPost
const [voteType, setVoteType] = useState();
useEffect(() => {
getVoteType();
}, []);
const [voteCount, setVoteCount] = useState(0);

const getVoteCount = async () => {
Expand Down Expand Up @@ -57,6 +54,7 @@ export default function BlogPost(props) {

useEffect(() => {
getVoteCount();
getVoteType();
}, []);

/**
Expand Down
34 changes: 12 additions & 22 deletions services/PostService.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ async function deletePostById(userCookie, postId) {
}
}



// async function changePostStatus(userCookie, postId, statusUpdate) {
// try {
// const { data } = await axios.post(
Expand Down Expand Up @@ -221,7 +219,7 @@ async function getPostsByQuery(query, clickNo) {
* @returns {Promise}
*/

async function getUserPostsByUser(UserId, reqParams) {
async function getUserPostsByUser(UserId, reqParams) {
try {
const res = await axios.get(`${baseUrl}/${postUser}/${UserId}`, {
params: reqParams
Expand Down Expand Up @@ -254,11 +252,9 @@ async function getPostsByQuery(query, clickNo) {
* @param {String} postId
* @returns {Promise}
*/
async function getVotes(postId) {

async function getVotes(postId) {
try {
const { data } = await axios.get(
`${baseUrl}/${getVoteUrl}/${postId}`);
const { data } = await axios.get(`${baseUrl}/${getVoteUrl}/${postId}`);
return data;
} catch (err) {
console.log(err);
Expand All @@ -267,10 +263,8 @@ async function getPostsByQuery(query, clickNo) {
}

async function getVotesType(postId) {

try {
const { data } = await axios.get(
`${baseUrl}/${getVoteTypeUrl}/${postId}`);
const { data } = await axios.get(`${baseUrl}/${getVoteTypeUrl}/${postId}`);
return data;
} catch (err) {
console.log(err);
Expand All @@ -279,12 +273,10 @@ async function getVotesType(postId) {
}

async function setVotes(value, postId) {

try {
const { data } = await axios.post(
`${baseUrl}/${setVoteUrl}/${postId}`,
{ value: value }
);
const { data } = await axios.post(`${baseUrl}/${setVoteUrl}/${postId}`, {
value: value
});
return data;
} catch (err) {
console.log(err);
Expand All @@ -295,16 +287,14 @@ async function setVotes(value, postId) {
/**
* Service to call PostCount Api
* @author JasirTp
* @param {String} userId
* @param {String} userId
* @returns {Promise}
*/
async function getPostCount(userId, postDetails) {

async function getPostCount(userId, postDetails) {
try {
const { data } = await axios.get(
`${baseUrl}/${postCount}/${userId}`,{
params: postDetails
});
const { data } = await axios.get(`${baseUrl}/${postCount}/${userId}`, {
params: postDetails
});
return data;
} catch (err) {
console.log(err);
Expand Down

0 comments on commit 2fcad17

Please sign in to comment.