You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

前端开发者求助:可临时存储REST API数据的存储渠道推荐

Hey there! As a fellow frontend dev who’s been exactly where you are—scratching my head for quick data storage to show off demos without waiting on backend teams—I’ve got some practical, tried-and-true options to share with you.

临时Demo用的REST API存储方案

These are perfect when you need something up and running in minutes, no complex setup required:

  • JSON Server: My go-to for local demos. Just create a db.json file with your sample data, run npx json-server --watch db.json, and boom—you’ve got a full REST API with GET/POST/PUT/DELETE endpoints. It even supports filtering, sorting, and pagination out of the box. Super easy to tweak data on the fly as you walk through the demo with clients.
  • Mockaroo: If you need realistic, structured mock data (like fake user profiles, order histories, etc.), this tool lets you generate custom datasets and either export them as JSON or use their hosted API endpoint to return the data directly. Great for making demos feel more polished with real-looking data.
  • Browser Storage (LocalStorage/SessionStorage): For super simple, client-only demos, you can store your API data directly in the browser. Just stringify your JSON data and save it:
    const demoData = [{ id: 1, title: "Sample Item" }, { id: 2, title: "Another Item" }];
    localStorage.setItem("demoApiData", JSON.stringify(demoData));
    
    Then fetch it back with JSON.parse(localStorage.getItem("demoApiData")) whenever you need it. No external tools needed at all.
  • In-Memory Mock Functions: If you don’t want to mess with files or external services, just write a quick mock function in your code that returns fake data as a promise. Example:
    const mockRestApi = {
      getItems: () => Promise.resolve([{ id: 1, name: "Demo Item" }]),
      createItem: (newItem) => Promise.resolve({ ...newItem, id: 3 })
    };
    
    This is ideal for ultra-fast demos where you just need to simulate API calls without any setup.
通用的REST API数据存储途径

If you’re looking for something that can grow with your project or work for more than just one-off demos, these are solid choices:

  • Backend-as-a-Service (BaaS) Platforms: Tools like Firebase Realtime Database/Firestore or Supabase give you ready-to-use REST (and even realtime) APIs right out of the box. You can set up a database in minutes, configure basic security rules, and call the API directly from your frontend. They’re great for moving from demo to production without a full backend rewrite.
  • Serverless Functions + Lightweight Databases: Pair serverless functions (like Vercel Functions or Netlify Functions) with a managed database (PlanetScale, Supabase, or even SQLite for simpler cases). You write small, focused functions to handle your API logic, and the database takes care of storage. It’s cost-effective, scalable, and gives you more control than BaaS if you need custom business logic.
  • Self-Hosted Lightweight Backend: If you prefer full control, spin up a simple Express server with a lightweight database like PostgreSQL or MySQL. You can write basic CRUD endpoints in an afternoon, and it’s easy to customize as your project grows. This is perfect if you already have experience with backend tools and want to keep your stack consistent.

At the end of the day, the best choice depends on how quickly you need it and how much flexibility you want. For quick client demos, JSON Server or browser storage are unbeatable. For longer-term projects, BaaS or serverless setups are great scalable options.

内容的提问来源于stack exchange,提问作者om_jaipur

火山引擎 最新活动