For the complete documentation index, see llms.txt. This page is also available as Markdown.

Storage.getItems

기능 설명

모바일 앱의 로컬 저장소에서 여러 문자열 값을 한 번에 가져와요. 앱이 종료되었다가 다시 시작해도 데이터가 유지돼요. 저장되지 않은 키도 결과에 포함되며 값은 null이에요.

토스앱 Android/iOS 5.270.0 이상에서 사용할 수 있어요. 호출 전에 Storage.getItems.isSupported()로 지원 여부를 확인할 수 있어요. 미지원 버전에서 호출하면 UNSUPPORTED_APP_VERSION 에러가 발생해요.

타입

Storage.getItems(keys: string[]): Promise<Record<string, string | null>>;

Params

type Keys = string[];

가져올 저장소 키 목록이에요.

Response

type GetItemsResult = Record<string, string | null>;

요청한 각 키와 저장된 값을 객체로 반환해요. 저장되지 않은 키의 값은 null이에요.

에러

코드
설명

UNSUPPORTED_APP_VERSION

실행 중인 토스앱 버전이 이 기능을 지원하지 않으면 호출 즉시 발생해요. Storage.getItems.isSupported()로 사전 확인하고, 발생 시 error.message를 사용자에게 보여주세요.

예시 코드

import { Storage } from "@apps-in-toss/web-framework";

if (Storage.getItems.isSupported()) {
  const items = await Storage.getItems(["theme", "language"]);
  console.log(items.theme);
  console.log(items.language);
}

도움이 되었나요?