This project demonstrates how to submit JSON data through a web form and then display the submitted data's key-value pairs in an organized manner.
- Level 1: Leve -l
- Level 2 and Level 3 : Repo
- Deployed link : Exact-Space
- Enter JSON data in a textarea.
- Validate and submit the JSON data to a backend API.
- Display the key-value pairs of the submitted JSON data on the page.
- Basic knowledge of HTML, CSS, and JavaScript.
- Node.js installed on your system.
-
Clone this repository or download the provided files.
-
Install the necessary dependencies using npm:
npm install express cors
-
Start the backend server:
node index.js
-
Open the
index.html
file in a web browser to access the application.
-
Open the web application in your browser.
-
Enter valid JSON data into the textarea and click the "Submit" button.
-
If the entered data is valid JSON, it will be sent to the backend API.
-
The backend API will respond with the submitted JSON data.
-
The submitted JSON data's key-value pairs will be displayed below the form.
index.js
: Backend server code using Express and CORS middleware.index.html
: Frontend HTML code containing the form and display area.index.css
: CSS styling for the frontend.index.js
: Frontend JavaScript code for form submission and displaying data.
The backend server is built using Express.js to handle POST requests with JSON data. CORS middleware is used to allow cross-origin requests.
The frontend form allows users to enter JSON data in a textarea and submit it. The data is then validated and sent to the backend API using the Fetch API.
The submitted JSON data's key-value pairs are displayed in a structured format below the form. The displayData
function in the frontend JavaScript dynamically creates HTML elements to display the key-value pairs.
- SweetAlert2 - Used for displaying success and error messages.
- Express.js - Backend server framework.
- CORS - Cross-Origin Resource Sharing middleware for Express.
For any questions or feedback, please contact Ayush kr shanu.