본 내용은 sw스터디에서의 내용을 토대로 작성했습니다.
1. 앞으로 함께할 코드들
npm init -y
npm i -S node-fetch(http request를 보낼 수 있음)
ㅇㅇ
touch main.js
터미널로 파일 만들기
const fetch = request('node-fetch');
const main = async () => {
};
main();
Printf랑 같은 console.log("hello");
node main
으로 진행
2. JavaScript 기본
- 자료형
대충 json 이해해라는 뜻
- 반복문 조건문
- callback(비동기)
콜백이 필요한 이유?
자바스크립트, "나는 한 번에 하나만 처리(동기)한다네"
개발자, "그럼 기다려야 해...?", "고럼 비동기!"
+ 이벤트루프를 공부하자!
- promise
callback hell? (공부하면서 추가)
-> async await
3. (과제) JavaScript
10번 평균 4sec
1번째 getUserIds
domain: https://zelight.vercel.app/
(required)
- headers
- permission: YYYYMMDD
Api1:
- endpoint: /api/20210608/getUserIds
- method: GET
- query: {}
- res
{
success: { type: Boolean },
error: { type: String },
data: {
userIds: { type: [String] },
},
}
Api2:
- endpoint: /api/20210608/getUserDetails
- method: GET
- query: { userId: { type: String } }
- res
{
success: { type: Boolean },
error: { type: String },
data: {
user: {
id: { type: String } ,
name: { type: String },
major: { type: String },
studentId: { type: String },
graduation: { type: Boolean },
},
},
}
Api3:
- endpoint: /api/20210608/getUserOriginByName
- method: GET
- query: { userName: { type: String } }
- res
{
success: { type: Boolean },
error: { type: String },
data: {
name: { type: String },
Origin: { type: String },
},
}