Okay, so continuing with the Collegues project, this is part two. Last time, I got the basic setup done – you know, the database connected and the first endpoint working. Today, I wanted to add a few more features to make it a bit more functional.

First thing I did was create a new endpoint to, well, add new colleagues. It’s pretty straightforward. I grabbed the data from the request body – name, department, and contact info, you know, the usual stuff.
Then I wrote a simple SQL query to insert this data into the ‘colleagues’ table. Nothing fancy, just a regular `INSERT` statement. I made sure to handle any potential errors, like if the database connection was down or something. Gotta keep it robust, right?
Adding the “Get All” Feature
After getting the “add” part working, I moved on to building a way to retrieve all the colleagues I’d added. So I created another endpoint for this, a `GET` request this time. Again, the SQL was pretty simple – a basic `SELECT FROM colleagues`.
- Fetch all the rows.
- Convert the data into a JSON format.
- Send it back as the response.
I did some Error Handling
I tested it out by adding a few dummy colleagues and then hitting the “get all” endpoint. Boom! It worked. I saw the list of colleagues pop up in the response. Felt good, man. It made good sense to go and do some error handling
So, yeah, that’s where I’m at with Collegues part two. I added a way to add new colleagues and a way to get a list of all of them. Next up, I’m thinking of adding features to update existing colleague info and maybe even delete them. Baby steps, you know? But it’s coming along nicely!