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.
- 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.
To use this fake REST API, follow these steps:
- Clone the repository:
git clone https://github.com/y0geshthakur/mobile.git
- Navigate to the project directory:
cd mobile - Install
json-serverif you haven't already:npm install -g json-server
- Start the JSON server with the provided JSON file:
This will start the fake REST API server on
json-server --watch db.json --port 5000
http://localhost:5000.
- Access the fake API endpoints at
http://localhost:5000to retrieve data. - Modify the
db.jsonfile to change the data as needed. - Use this API in your frontend application for development and testing.
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;Contributions are welcome! Please fork this repository and submit a pull request for any features, bug fixes, or improvements.
This project is licensed under the MIT License.
For any questions or inquiries, please contact me at Yogesh Thakur.