API Calling not working consistent

Hi Guys

Until a few weeks ago, the API worked very well and there was never a problem, but now the error occurs every now and then:

Unexpected identifier ‘Connecting’ [:1:35]

What could be the reason?

The API Call is the following:

$(eval var message = ""; var api = $(urlfetch json https://illupy.ch:8080/api/v1/csgo/faceit/user/Pimp?duration=d); message = 'Elo: ' + api['Faceit-Api']['elo'] + ' Today -> Win:' + api['Faceit-Api']['Win'] + ' Lose:' + api['Faceit-Api']['Loss'] + ' Elo:' + api['Faceit-Api']['Elo Today'] ; if(api['Faceit-Api']['Elo Today'] < 0) { message += " 📉 " ;} else { message += " 📈 " ;}  message)

Thanks for any help

It looks like an issue on the API’s side? Maybe it doesn’t answer fast enough (are you hosting it locally? that could be it), or it responds with an error. Have you checked the API in a browser whenever this error message appears?

By the way, you can improve your code a bit:

$(eval let api = $(urlfetch json https://illupy.ch:8080/api/v1/csgo/faceit/user/Pimp?duration=d)['Faceit-Api']; let message = `Elo: ${api.elo} Today -> Win: ${api.Win} Lose: ${api.Loss} Elo: ${api['Elo Today']}`; api['Elo Today'] < 0 ? message += ' 📉' : message += ' 📈'; message)

I believe you have control over the API? In which case, may I suggest following the best practices when building an API that responds with JSON: avoid keys with spaces or dashes -, prefer camelCase, the reason is because otherwise you need to use brackets [] to reach the values.

Hey Emily,

thanks for your response.
The API is hostet on a VM and is reachable in ms…

about your feedback of the API i agree, that just went over time but a good idea to make it better.

I will see if the API has a hanger or the webservice when it happens.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.