728x90
Express에서 axios로 response를 받았을 때, alert를 띄워야 하는 상황이 있었다.
이 때 alert의 안내 메세지로 나오는 한글들이 깨지는 현상이 발생해서 이를 해결하는 과정을 기록해 보았다.
해결방법은 간단한데, 다음과 같이 해결하면 된다.
.then((res) => {
}).catch((error) => {
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'})
res.write('<script type="text/javascript">alert("실패");history.back();</script>')
})
728x90
'Node.js > Express' 카테고리의 다른 글
Express 공식 문서 보고 배운 내용 정리 (0) | 2022.08.20 |
---|