I have been stuck for a while in Exercise Tracker project in this part:
" You can
/api/users/:_id/exercises with form data
duration , and optionally
date . If no date is supplied, the current date will be used. The response returned will be the user object with the exercise fields added."
I don’t understand how can i send a parameter with the POST request from an HTML form. Or should i use some on submit function and then send a post request with fetch/axios ?
Thank you in advance !
Challenge: Exercise Tracker
Link to the challenge:
Could you explain about which parameter or parameters you are not sure?
Hey, thank you for reply, i am talking about the _id parameter in the url. I mean that i have the form in index.html which have the action (the url specified above) and a method (post). How can i get the text from the input and dinamycally change the url in the form action ?
Generally yes, it most likely will need to be added to the POST url after form is submitted. There’s multiple ways to do that, depending how you’d like to handle it. Simpler approach, than doing something with
fetch function, might be just changing the action url of the form.
I was just having the exact same problem with you and keep looking around online till i saw ur questions
i just found out what happening so i will leave here in case u need it
at first i thought that the POST method need to be created is only for the form element in the html, but the solution checker are not going to call the that post method from the form element but instead calling it using the URL with id as the request parameters.
so i end up making two one for the html form and one for the solution checker
hope this help
Thank you ! It is helped but currentlly i still cant pass the test… Which format should the json response be … ? , I am trying this by the instruction but it won’t work:
duration: … ,
Problem solved !
Thanks to everyone for the notes, the issue was because i assigned shortId to the user created JSON response and the test used that for that test also (concat the id to the url params), second issue was the object format (the test uses deepEqual than it should be exactly the same).
Wow, thanks! I’m really glad I came here before too much googling.
Some of these projects seem pretty broken
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.