local-fake-api
Version:
A simple async local mock API without backend.
10 lines (9 loc) • 390 B
JavaScript
import { createLocalStorageApi } from "./localStorageApi";
import { createIndexedDbApi } from "./indexedDbApi";
export function createFakeApi(tableName, options = {}) {
const { primaryKey = "id", storage = "idb" } = options;
if (storage === "localStorage") {
return createLocalStorageApi(tableName, primaryKey);
}
return createIndexedDbApi(tableName, primaryKey);
}