일반
JSON()을 사용할 때 주의할 점.
알 수 없는 사용자
2022. 11. 27. 20:26
SMALL
useEffect(() => {
axios
.get(`http://localhost:4000/settingitems?Name=EOperator`)
.then((response) => {
let data = response.data[0].Value;
data = data.replaceAll("`", '"');
let parsedValue = JSON.parse(data);
setAttached(parsedValue?.Attached);
setPosition(parsedValue?.Position);
setName(parsedValue?.Name);
setPhone(parsedValue?.Phone);
changeActorInfo(parsedValue);
});
}, []);
정보를 가져왔을 때 `(백틱)부분을 " <-로 바꾼 후에 parse를 해줘야 적용이 되더라.
LIST