[240731] TIL
μ€λ λ°°μ΄ κ²
1. Base64 μμ Json λ³ν μλλ μ€λ₯
Unexpected token < in JSON at position 0
- μμ κ°μ μ€λ₯ κ³μ λ°μν¨
- base64 URL-safe (URL-encoded Base64) λ‘ μΈμ½λ©νλ©΄ json λ³ν κ°λ₯
νΉμ± | Base64 | Base64 URL-safe |
---|---|---|
μ¬μ© λ¬Έμ | A-Z, a-z, 0-9, +, / | A-Z, a-z, 0-9, -, _ |
ν¨λ© λ¬Έμ | = | λ³΄ν΅ μλ΅λκ±°λ μ¬μ© μ ν¨ |
URLμμμ μμ μ± | μμ νμ§ μμ | μμ ν¨ |
μΌλ°μ μΈ μ¬μ© μ¬λ‘ | MIME μΈμ½λ©, μ΄λ©μΌ μ μ‘ λ± | URL, 쿼리 μ€νΈλ§, JSON, νμΌ μ΄λ¦ |
export const arrayBufferToBase64URL = (buffer: ArrayBuffer): string => {
let binary = "";
const bytes = new Uint8Array(buffer);
const len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window
.btoa(binary)
.replace(/=/g, "")
.replace(/\+/g, "-")
.replace(/\//g, "_");
};
2. μ격 ν΅μ
http ν΅μ μ ν΄λΌμ΄μΈνΈμ μλ² ν΅μ λ°©λ² μ€μ νλ
μ격 ν΅μ μ grpc graphql http, μΉμμΌ λͺ¨λλ₯Ό μ΄κ΄νλ νν
3. λ₯λ€μ΄λΈ 46μ₯ μ λλ μ΄ν°μ async/await
- μ½κ³ λ Έμ μ μ 리
Leave a comment