티스토리 뷰
개발 TIL
Node JS promisify
함수를 promise 화 해주는 함수이다. util 라이브러리를 가져와서 사용해야 한다.
import util from 'util';
util.promisify();
async 함수에서 await 반환을 금지하는 ESLint가 있다.
async
함수는 반환값을 Promise로 감싸 반환하기 때문에 fetch 함수를 await
한 값을 바로 내보내면 의미가 없다고 보는 의견도 있다.
const fetchData = async() => {
return await fetch('url');
}
const response = await fetchData();
response.json() 메서드는 비동기 함수이다.
fetch 메서드로 데이터를 받아오면 항상 return response.json()
이라고 관용적으로 사용했다. 어차피 받아서 사용하는 곳에선 await를 사용하기 때문에 별 신경을 안 썼는데 response.json()
은 비동기 함수이다.
const fetchData = async() => {
try {
const response = await fetch();
if (response.ok) {
return response.json(); // 비동기임!
}
} catch(error) {
console.log(error);
}
}
영어 TIL
- 경영진은 사무실에서 엄격한 복장 규정을 시행하기로 했습니다.
Coperate has decide to implement strcit dress code in the office. - 즐거운 저녁 보내길 바라!
I hope you have a pleasant evening! - 내 생각엔 꽤 잘된 것 같아. 너도 그렇게 생각하지 않니?
I think that went rather well actually, don't you? - 단 한명도 빼놓지 않고 모두 회의실로 모이도록 해!
I want every single one of you in the meeting room! - 미세먼지
fine dust - 그는 싱글인 척 하고 있던 거야.
He's just pretending to be single. - 북한이 남한을 처음 침공한 건 언제였나요?
When did North Korea first invade South Korea? - 경보기는 도둑들이 침입하는 것을 막기 위함입니다.
The alarm is to stop theives from breaking in.