Skip to content

Commit

Permalink
Merge pull request #176 from boostcampwm2023/fix/175-default-shape-to…
Browse files Browse the repository at this point in the history
…-user-shape

[Fix] 사용자별 전체 모양 API로 변경
  • Loading branch information
dbwhdtjr0457 authored Nov 30, 2023
2 parents 410d3e4 + c7a79b0 commit f62df5a
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions FE/src/pages/MainPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,25 @@ function MainPage() {
});

async function getShapeFn() {
return fetch("http://223.130.129.145:3005/shapes/default", {
return fetch("http://223.130.129.145:3005/shapes/", {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${userState.accessToken}`,
},
})
.then((res) => res.json())
.then(async (data) => {
const shapeDataList = data.map((shape) =>
fetch(`http://223.130.129.145:3005/shapes/${shape.uuid}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${userState.accessToken}`,
},
}).then(async (res) => ({
uuid: shape.uuid,
data: await res.text(),
})),
);

setShapeState(
await Promise.all(shapeDataList).then((res) =>
res.map((shape) => {
const newShape = {
...shape,
data: shape.data.replace(/<\?xml.*?\?>/, ""),
};
return newShape;
}),
),
);
setShapeState(() => {
let shapeList = [];
for (let key in data) {
shapeList.push({
uuid: data[key].uuid,
data: data[key].svg.replace(/<\?xml.*?\?>/, ""),
});
}
return shapeList;
});
});
}

Expand Down

0 comments on commit f62df5a

Please sign in to comment.