Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Mobile Application - Fake REST API

This repository contains a JSON file used as a fake REST API for testing and development purposes. This can be particularly useful for frontend developers to simulate API responses and test their applications without the need for a real backend.

Features

  • Simulates API responses: Provides a mock backend for development and testing.
  • Easy to set up: Can be quickly integrated into your project using tools like json-server.
  • Customizable: Modify the JSON file to fit your specific needs.

Installation

To use this fake REST API, follow these steps:

  1. Clone the repository:
    git clone https://github.com/y0geshthakur/mobile.git
  2. Navigate to the project directory:
    cd mobile
  3. Install json-server if you haven't already:
    npm install -g json-server
  4. Start the JSON server with the provided JSON file:
    json-server --watch db.json --port 5000
    This will start the fake REST API server on http://localhost:5000.

Usage

  • Access the fake API endpoints at http://localhost:5000 to retrieve data.
  • Modify the db.json file to change the data as needed.
  • Use this API in your frontend application for development and testing.

Example

Here is a basic example of how you might use this fake API in a React application:

// Example React component to fetch data from the fake API
import React, { useEffect, useState } from 'react';

const ExampleComponent = () => {
  const [data, setData] = useState([]);

  useEffect(() => {
    fetch('http://localhost:5000/your-endpoint')
      .then(response => response.json())
      .then(data => setData(data))
      .catch(error => console.error('Error fetching data:', error));
  }, []);

  return (
    <div>
      <h1>Data from Fake API</h1>
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
};

export default ExampleComponent;

Contributing

Contributions are welcome! Please fork this repository and submit a pull request for any features, bug fixes, or improvements.

License

This project is licensed under the MIT License.

Contact

For any questions or inquiries, please contact me at Yogesh Thakur.


Return to Yogesh Thakur's GitHub Profile

About

Fake Rest API

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors