일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- Git
- styled components
- github
- npm styled-reset
- icon
- nextjs
- react
- dart 변수
- There isn’t anything to compare
- nextjs .env
- fetch
- rewrites
- git lab
- createGlobalStyle
- ngrok설치
- getModifierState
- next.js css
- github io
- CSS
- react env
- SCSS
- API token
- typescript react
- 컨디셔널 렌더링
- input type=file
- API 토큰
- bootstrap
- ngrok실행
- react typescript
- nextjs 설치
- Today
- Total
목록fetch (2)
꾸준히 성장하는 개발자

Promise :자바스크립트 비동기 처리에 사용되는 객체 Promise 객체는 비동기 작업이 맞이할 미래의 완료 또는 실패와 그 결과 값을 나타냅니다. 대기(pending): 이행하지도, 거부하지도 않은 초기 상태. 이행(fulfilled): 연산이 성공적으로 완료됨. 거부(rejected): 연산이 실패함. Promise를 공부해보자 fetch로 json파일을 불러오면 let fetched = fetch("https://jsonplaceholder.typicode.com/posts"); console.log(fetched) // Promise{...} fetch는 Promise 객체를 반환한다 promise는 두 개의 메서드를 사용할 수 있는데 then과 catch이다. 둘 다 콜백 함수를 받는다. ...
1. fetch( ).then( ) fetch("https://jsonplaceholder.typicode.com/posts") .then((res) => { return res.json(); }) .then((obj) => { console.log(obj); }); 2. axios / async await axios Promise 기반의 HTTP 비동기 통신 라이브러리 Fetch와 Axios의 차이점은 Axios는 요청과 응답을 모두 JSON 형식으로 자동 변환시켜 줍니다. async await Promise 객체를 사용하더라도 .then() .catch() 등등 뒤에 붙이는 것들이 많아진다. 뒤에 뭐 안 붙이고, 더 간단하게 비동기 작업을 동기적으로 만들어주는 키워드가 바로 await 이다. cons..