Notice
Recent Posts
Recent Comments
Link
250x250
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- package.json
- npm install 문제
- MediaQuery
- Git clone
- git lab clone
- XEIcon
- 글자들여쓰기
- vscode git clone
- node 오류
- minwidth
- node설치
- 단어단위로떨어지기
- 플러그인
- legacy-peer
- npm install
- owlcarousel
- npm start
- 정적객체
- googleicon
- 그누보드반응형
- slickslider
- window 정책변경
- maxwidth
- 웹아이콘
- 이미지반응형
- 의존성문제
- react npm install
- 동적객체
- 아이콘사용법
- fontawesome
Archives
- Today
- Total
어쩌다 알게 된 ƪ(•̃͡•̃͡ ƪ
[FE] 서버 로고 src 받아오기 본문
728x90
const encoded = new URLSearchParams(window.location.search).get("data");
const { state, result, message, logo } = JSON.parse(Base64.decode(decodeURIComponent(encoded)));
** const encoded = new URLSearchParams(window.location.search).get("data");
👩💻 window.location.search
=> 현재 URL의 ? 뒤에 붙은 쿼리스트링 전체
ex) https://example.com/callback?data=test
여기서의 값은 ?data=test 가 됨
👩💻 .get("data")
=> 가져온 값에서 data에 해당하는 값만 꺼냄
ex) 위에 껄로 치면 값이 test 가 됨
** const { state, result, message, logo } = JSON.parse(Base64.decode(decodeURIComponent(encoded)));
👩💻 decodeURIComponent(encoded)
=> URL 인코딩을 원래 문자로 복원
ex) %3D → =
"eyJzdGF0ZSI6IlNVQ0NFU1MiLCJsb2dvIjoiLi4uIn0="
👩💻 Base64.decode(...)
=> Base64 문자열 → 일반 문자열로 복호화
현재 문자열 상태
{"state":"SUCCESS","result":true,"message":"OK","logo":"..."}
👩💻 JSON.parse(...)
=> JSON 문자열 → JS 객체 로 변경
{
state: "SUCCESS",
result: true,
message: "OK",
logo: "..."
}
👩💻 const { state, result, message, logo } = ...
=> 구조분해 할당
=> 필요한 값만 꺼내 쓰기
** 아래와 같음
const data = JSON.parse(...);
const state = data.state;
const result = data.result;
const message = data.message;
const logo = data.logo;
728x90
'자바스크립트 > ⚪️ Vanilla' 카테고리의 다른 글
| [Js] 구조 분해 (0) | 2025.04.25 |
|---|---|
| [JS] response, response.data 비동기 함수 응답 처리, axio.get().then((response) => {}); (0) | 2025.04.11 |
| ⚪️ [JS] JSON.stringify() (0) | 2025.03.25 |
| ⚪️ [JS] setInterval, setTimeout이랑 비슷한 Throttle, Debounce (0) | 2025.03.22 |
| ⚪️ [JS] 디버깅시 console 사용 꿀팁 (0) | 2025.03.21 |
Comments