Skip to content

Commit

Permalink
fix : fix API_3
Browse files Browse the repository at this point in the history
  • Loading branch information
raylee0519 committed Aug 4, 2022
1 parent 67f6b79 commit 9a696d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
6 changes: 3 additions & 3 deletions frontend/src/components/mainpage/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ const SearchBar = () => {
const [input, setInput] = useState("");
let navigate = useNavigate();

const onSubmit = (input: string) => {
axios
.post(`http://localhost:8080/api/search/`, { value: input })
const onSubmit = async(input: string) => {
await
Api.post(`/search/`, { value: input })
.then((response) => {
let trashIMG = "";
for (let j = 0; j < 6; j++) {
Expand Down
35 changes: 19 additions & 16 deletions frontend/src/components/mainpage/TrashCardView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@mui/material";
import axios from "axios";
import useScrollFadeIn from '../../modules/useScrollFadeIn';
import Api from "../../utils/customApi";

interface BaseContent {
kind: string;
Expand Down Expand Up @@ -82,26 +83,28 @@ function MultiActionAreaCard() {
const [secondData, setSecondData] = useState<BaseContent | null>(null);
const [thridData, setThirdData] = useState<BaseContent | null>(null);

axios
.get("http://localhost:8080/api/trash/statistics/ranking")
.then((response) => {
for (let i = 0; i < 3; i++) {
trashlist[i].kind = response.data[i].kind;
for (let j = 0; j < 6; j++) {
if (ranklist[j].kind === trashlist[i].kind) {
trashlist[i].images = ranklist[j].images;
const getRanking = async () => {
await Api.get(`/trash/statistics/ranking`)
.then((response) => {
for (let i = 0; i < 3; i++) {
trashlist[i].kind = response.data[i].kind;
for (let j = 0; j < 6; j++) {
if (ranklist[j].kind === trashlist[i].kind) {
trashlist[i].images = ranklist[j].images;
}
}
}
}


setFirstData(trashlist[0]);
setSecondData(trashlist[1]);
setThirdData(trashlist[2]);
})
.catch((error) => {
console.log("error", error.response);
});
setFirstData(trashlist[0]);
setSecondData(trashlist[1]);
setThirdData(trashlist[2]);
})
.catch((error) => {
console.log("error", error.response);
});
getRanking();
}

return (
<Grid container
Expand Down

0 comments on commit 9a696d3

Please sign in to comment.