API Server Running localhost:3000
Node.js v20 · Express 4.x · MySQL2 · (simulated in-browser)
API Endpoints
GET /api/students Get all
GET /api/students/:id Get one
POST /api/students Create
PUT /api/students/:id Update
DELETE /api/students/:id Delete
API Console — Request Log
// Student Record System API
// Built with Node.js + Express.js + MySQL2
// Interact using the form on the right →
Express.js Route Sample
const express = require('express');
const router  = express.Router();
const db     = require('./db');

// GET all students
router.get('/', async (req, res) => {
  const [rows] = await db.query(
    'SELECT * FROM students');
  res.json(rows);
});

// POST create student (with validation)
router.post('/', async (req, res) => {
  const {name, course, year, gpa} = req.body;
  if (!name || !course || !year)
    return res.status(400)
      .json({error:'Missing fields'});
  const [r] = await db.query(
    'INSERT INTO students SET ?',
    [{name,course,year,gpa}]);
  res.status(201).json(
    {id:r.insertId,...req.body});
});
Add New Student POST /api/students
Name is required.
Course is required.
Year is required.
GPA must be between 1.0 and 5.0.
0 students
Last API Response (JSON)
// No request yet