簡體   English   中英

我一直在嘗試獲取 API recipepuppy.com 並且我不斷收到此消息:語法錯誤和 500 內部服務器錯誤

[英]I have been trying to fetch an API recipepuppy.com and I keep getting this : Syntax Error and 500 Internal server error

我使用了 recipepuppy api 並且在獲取項目時我無法獲得結果並且我一直收到此錯誤代碼是

search(){
    let {ingredients, dish} = this.state;
    const url =`http://www.recipepuppy.com/api/?i=${ingredients}&q=${dish}`;
    fetch(url, {
    method: 'GET'
    }).then(response => response.json())
    .then(json => console.log('recipes', json));
}

我在控制台中收到此錯誤

SearchRecipes.js:17          GET http://www.recipepuppy.com/api/?i=garlic,chicken&q=adobo 500 (Internal Server Error)
search @ SearchRecipes.js:17
onClick @ SearchRecipes.js:49
callCallback @ react-dom.development.js:189
invokeGuardedCallbackDev @ react-dom.development.js:238
invokeGuardedCallback @ react-dom.development.js:291
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:306
executeDispatch @ react-dom.development.js:391
executeDispatchesInOrder @ react-dom.development.js:416
executeDispatchesAndRelease @ react-dom.development.js:3301
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:3310
forEachAccumulated @ react-dom.development.js:3282
runEventsInBatch @ react-dom.development.js:3327
runExtractedPluginEventsInBatch @ react-dom.development.js:3537
handleTopLevel @ react-dom.development.js:3581
batchedEventUpdates$1 @ react-dom.development.js:21729
batchedEventUpdates @ react-dom.development.js:798
dispatchEventForLegacyPluginEventSystem @ react-dom.development.js:3591
attemptToDispatchEvent @ react-dom.development.js:4311
dispatchEvent @ react-dom.development.js:4232
unstable_runWithPriority @ scheduler.development.js:659
runWithPriority$1 @ react-dom.development.js:11077
discreteUpdates$1 @ react-dom.development.js:21746
discreteUpdates @ react-dom.development.js:811
dispatchDiscreteEvent @ react-dom.development.js:4211
VM1141:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 91 

請在這件事上給予我幫助

問題不在你這邊,這個 API 沒有正確發送正文數據,並將 HTML 字符串連接到 JSON 響應上,因此你實際上無法正確解析響應。 如果這不是您的 API,請聯系所有者並告知他們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM