Hi !
I am finishing the “LEARN EXPRESS ROUTES” exercise in the “Learn Express” course.
Learn Express: Create a Server | Codecademy
https://www.codecademy.com/paths/web-development/tracks/javascript-back-end-development/modules/learn-express-create-a-server/lessons/learn-express-routes/exercises/creating-an-expression
I experimented with curl commands to simulate the functions in the programme.
I click the plus (+) sign in the bash command line and execute these command:
Get all expressions
curl --request GET localhost:4001/expressions/
// [{“id”:1,“emoji”:“”,“name”:“happy”},{“id”:2,“emoji”:“
”,“name”:“shades”},{“id”:3,“emoji”:“
”,“name”:“sleepy”}]
Get expression with id
curl --request GET localhost:4001/expressions/2
// {“id”:2,“emoji”:“”,“name”:“shades”}
Update expression with id
curl --request PUT localhost:4001/expressions/3?name=also_shades&emoji=%F0%9F%98%80
// {“id”:3,“emoji”:“”,“name”:“also_shades”}
Delete expression with id
curl --request DELETE localhost:4001/expressions/3
curl --request GET localhost:4001/expressions/
// [{“id”:1,“emoji”:“”,“name”:“happy”},{“id”:2,“emoji”:“
”,“name”:“happy”}]
But - I cannot get the curl POST request to work.
I tried this:
curl --request POST localhost:4001/expressions?name=another_shades&emoji=%F0%9F%98%80
When I console.log(req.query)
it only contain the first part of the query string i.e. “name=another_shades”. “emoji=%F0%9F%98%80” is not part of the req.query.
Do anyone have an idea on what is wrong - what could be a solution?