Skip to content

Commit

Permalink
#17 [Fix] fix vote post axios
Browse files Browse the repository at this point in the history
  • Loading branch information
eunbis committed Aug 1, 2022
1 parent 524197f commit 6b1d099
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/apis/Vote.apis.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import { serverAxios } from './index';

const PREFIX_URL = 'api/v1/votes';
Expand Down Expand Up @@ -40,3 +41,16 @@ export const GetUserVote = async (userId, votePostsId) => {
return err;
}
};

export const PostVotes = async (privateAxios, place, clothes) => {
try {
const { data } = await privateAxios.post(`${PREFIX_URL}`, {
building: place.length > 0 ? place : 'ํ•™๊ต',
clothes: clothes,
});
console.log(data);
return data;
} catch (err) {
return err;
}
};
7 changes: 6 additions & 1 deletion src/pages/Vote/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable */
import React, { useState, useParams } from 'react';
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { PostVotes } from 'apis/Vote.apis';
import { usePrivateAxios } from 'hooks';
import { WhiteLeft } from 'assets';
import { HeaderIcon, PublicButton } from 'components';
import {
Expand All @@ -19,6 +21,8 @@ import {
} from './style';

function Vote() {
const privateAxios = usePrivateAxios();

const navigate = useNavigate();

const [clothes, setClothes] = useState('');
Expand Down Expand Up @@ -89,6 +93,7 @@ function Vote() {
<ButtonBox>
<PublicButton
onClick={() => {
PostVotes(privateAxios, place, clothes);
navigate(
`/votecomplete/${clothes}/${place.length > 0 ? place : 'ํ•™๊ต'}`,
);
Expand Down

0 comments on commit 6b1d099

Please sign in to comment.