Problem: Fetch in React for Leaderboard [SOLVED]


#1

Trying to grab the info off of https://fcctop100.herokuapp.com/api/fccusers/top/recent

by using

	<script type="text/babel">

fetch("https://fcctop100.herokuapp.com/api/fccusers/top/recent")
	.then(
		function(response) {
			console.log(response)
		}
	)

</script>	

but it is returning

Response {type: "cors", url: "https://fcctop100.herokuapp.com/api/fccusers/top/recent", redirected: false, status: 200, ok: true…}

I tried this for several endpoints and the result is always 200 - any way I can use fetch for this or do I have to request the data in another way?


#2

200 is good

The response data is accessed with response.json()

fetch("https://fcctop100.herokuapp.com/api/fccusers/top/recent")
	.then(function(response) {return response.json()})
	.then(data => console.log(data))

#3

lol, to my tired mind it was an error code - thank you :slight_smile: