Test: Fetch to chess.com JSON #2

Sort:
Avatar of 2k11dentusapa

Avatar of Tricky_Dicky

Looks dodgy. No information

Avatar of ThePanchalFamily

same

Avatar of stephen_33

I'm surprised Martin hasn't deleted that first post yet because it looks a lot like one posted a couple of months ago which fooled the site's code-blocking system.

Avatar of 2k11dentusapa
Tricky_Dicky đã viết:

Looks dodgy. No information

It's not malware bro

<p><input id="input" type="text"> <button style="width: 50px; height: 19px;" onclick="
  const inputValue = document.getElementById('input').value.trim();
  const getDataFromInput = fetch('https://api.chess.com/pub/club/' + inputValue);
  getDataFromInput.then(function f(getJson) {return getJson.json()}, function() {alert('Error fetching club data')}).then(function (data) {
    document.getElementById('result').innerHTML = `
                <h3>${data.name}</h3>
                <b>Club Name:</b> ${data.name} <br>
                <b>Country:</b> ${data.country} <br>
                <b>League:</b> ${data.league || 'null'} <br>
                <b>Verified:</b> ${data.verified} <br>
                <b>Club ID:</b> ${data.club_id} <br>
                <b>Profile:</b> <a href='${data.url}' target='_blank'>${data.url}</a>
            `
        });
">Click</button></p>
Avatar of MMMR70

can anyone explain what this button does i no some code but whe i type in something is it makeing and taking me to the club or is it taking me to a real club

Avatar of Tricky_Dicky

Having now seen the code (if that is what is behind the post) it returns club information from the api endpoint. It won't work 100% of the time. Some clubs have a different URL identifier to their literal name. And I don't recognize some of the output data fields.

Avatar of stephen_33

Slightly odd though because there aren't "league" or "verified" keys in the club endpoint, so it's not clear why they're included?

Avatar of stephen_33
Tricky_Dicky wrote:

Having now seen the code (if that is what is behind the post) it returns club information from the api endpoint. It won't work 100% of the time. Some clubs have a different URL identifier to their literal name. And I don't recognize some of the output data fields.

Yes, on that the input must be the club's url_id of the type: "chess-com-developer-community"

If you use a club's name you get an error. That isn't explained and is a rather serious omission in the first post I think?

An interesting piece of HTML but it really needs some additional work to be fully presentable.

Avatar of Guest4400951197
Please Sign Up to comment.

If you need help, please contact our Help and Support team.