Random Famous Quotes

부분 유료
분류별 Andres Olvera | 업데이트됨 4 days ago | Data
인기

9.5 / 10

지연 시간

469ms

서비스 수준

100%

Health Check

N/A

모든 토론으로 돌아가기

API not returning content

Rapid account: Dgullifo
dgullifo
hace 5 años

Using the JS fetch method, from inside html page, identical to the snippet.

This is what I get in the console:

Response {type: “cors”, url: “https://andruxnet-random-famous-quotes.p.rapidapi.com/?cat=famous&count=10”, redirected: false, status: 200, ok: true, …}
body: (…)
bodyUsed: false
headers: Headers {}
ok: true
redirected: false
status: 200
statusText: "OK"
type: "cors"
url: "https://andruxnet-random-famous-quotes.p.rapidapi.com/?cat=famous&count=10"
proto: Response

i.e. no valid response text. Any ideas what I am doing wrong? . Tks!

Rapid account: Payamazadi Natgeo
payamazadi-natgeo Commented hace 5 años

as i said earlier, add a user-agent header.

Rapid account: Dgullifo
dgullifo Commented hace 5 años

Update: the API return works when I add an extra promise to the fetch-based JS snippet:

})
.then(response => response.json()) << added to get the response to work as intended
.then(response => {
console.log(response);
})

I got the idea from this thread: https://stackoverflow.com/questions/33237200/fetch-response-json-gives-responsedata-undefined

Rapid account: Dgullifo
dgullifo Commented hace 5 años

OK so how do I share the code so that it will display correctly in this comment box? --It looks like the parser substitutes for all the <> and completely hides the javascript…

Rapid account: Andruxnet
andruxnet Commented hace 5 años

Are you using a GET request or a POST request? If it is a GET request, could you please share your code for me to try it?

아래에 의견을 추가하고 토론에 참여하세요.

새 댓글을 게시하려면 로그인 / 가입