complete-javascript-course
complete-javascript-course copied to clipboard
Forkify API Error: Request timed out
I've been learning with your course, and I find it amazing and all has been going smooth. Everything was fine before I went to bed last night, however, when I woke up this morning to continue with building the Forkify App, it keeps failing to generate data from the Forkify API. I visited the demo site (forkify-v2.netlify.app) and the same issue persisted. Please check kindly look into it.
when i try to visit this site https://forkify-api.herokuapp.com/api/v2/recipes/ i receive an error message { "status": "error", "message": "Something went very wrong!" } I would like to know how to resolve this
The /recipes
endpoint has a required search
parameter, so in order to make it work, you will need to pass some search query, for example, /recipes?search=pizza
.
I think the API should respond with a better message, and a different Http code in this case. We'll change it in the future.
Thanks akozdev i noticed it worked on the browser but I didn't think to try it out in the code as it looked a bit weird
However the goal was to sendJSON(url, recipe) but i get the error message so if i were to use this /recipes?search=pizza example i would get a list of pizza and not be able to send my own data
The
/recipes
endpoint has a requiredsearch
parameter, so in order to make it work, you will need to pass some search query, for example,/recipes?search=pizza
.I think the API should respond with a better message, and a different Http code in this case. We'll change it in the future. Thanks for your response However the goal was to sendJSON(url, recipe) but i get the error message so if i were to use this /recipes?search=pizza example i would get a list of pizza and not be able to send my own data
To upload a new recipe, send a POST
request to the /recipes
endpoint. In this case, you only need to provide your API key in the params, like this /recipes?key=<your key>
because POST
requests are handled differently on this endpoint.
The sendJSON() function should already be configured to send POST
requests
const fetchPromise = fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(uploadData),
});
To upload a new recipe, send a
POST
request to the/recipes
endpoint. In this case, you only need to provide your API key in the params, like this/recipes?key=<your key>
becausePOST
requests are handled differently on this endpoint.The sendJSON() function should already be configured to send
POST
requestsconst fetchPromise = fetch(url, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(uploadData), });
I am still getting error
helpers.js:33
GET https://forkify-api.herokuapp.com/api/v2/recipes?key=924ac711-1d3b-4ccf-8271-2cae6c20e0fb 500 (Internal Server Error)
sendJSON @ helpers.js:33 await in sendJSON (async) uploadRecipe @ model.js:140 controlAddRecipe @ controller.js:96 (anonymous) @ addRecipeView.js:40 controller.js:98 Error: Something went very wrong! 500 at sendJSON (helpers.js:35:24) at async Object.uploadRecipe (model.js:140:18) at async controlAddRecipe (controller.js:96:5)
I have seen the error an unused variable i was using fetch(url) when i had created a variable named fetchPro to store it already. Thanks a lot it was really helpful
You're welcome!