Server side API parsing data for frond end issue

Hi ,

I am trying to use in the server side the following api url with API connector “https://www.thesportsdb.com/api/v1/json/3/search_all_teams.php?l=English%20Premier%20League%20” . |I can retrieve it but i can’t use it in the frond-end.

Can someone can provide me how to change the type or convert it to be able to use it?

I use guidelines from other posts for JSON formatter , i made several tests but now i am stuck

I also tried this solution without luck : How would do an INSERT with JSON data from an API all in a server action?

Regards

What problems do you have? You can use it as any other server action displaying data on the page.

Setup your api step and fetch schema:

Then on the front end add your server action on the page, and use it as a source for the repeat:

And bind all the data you need:

1 Like

Teodor i can’t understand why when i doing the exact same things i can’t retrieve data from the server connect i am attaching also the web inspector tool results.

New teams

Id team Id soccer xml Id apifootball Int loved Str team Str team short Str alternate Int formed year Str sport Str league Id league Str league2 Id league2 Str league3 Id league3 Str league4 Id league4 Str league5 Id league5 Str league6 Id league6 Str league7 Id league7 Str division Str manager Str stadium Str keywords Str rss Str stadium thumb Str stadium description Str stadium location Int stadium capacity Str website Str facebook Str twitter Str instagram Str description en Str description de Str description fr Str description cn Str description it Str description jp Str description ru Str description es Str description pt Str description se Str description nl Str description hu Str description no Str description il Str description pl Str kit colour1 Str kit colour2 Str kit colour3 Str gender Str country Str team badge Str team jersey Str team logo Str team fanart1 Str team fanart2 Str team fanart3 Str team fanart4 Str team banner Str youtube Str locked

Please check:

also when posting code, please follow:

Preview of the response object:

api_list_teams: Object

data: Object

teams: Array (20)
0 {idTeam: “133604”, idSoccerXML: “9”, idAPIfootball: “42”, intLoved: “8”, strTeam: “Arsenal”, …}
1 {idTeam: “133601”, idSoccerXML: “5”, idAPIfootball: “66”, intLoved: null, strTeam: “Aston Villa”, …}
2 {idTeam: “134301”, idSoccerXML: “756”, idAPIfootball: “35”, intLoved: “2”, strTeam: “Bournemouth”, …}
3 {idTeam: “134355”, idSoccerXML: “811”, idAPIfootball: “55”, intLoved: “1”, strTeam: “Brentford”, …}
4 {idTeam: “133619”, idSoccerXML: “24”, idAPIfootball: “51”, intLoved: null, strTeam: “Brighton”, …}
5 {idTeam: “133610”, idSoccerXML: “15”, idAPIfootball: “49”, intLoved: “5”, strTeam: “Chelsea”, …}
6 {idTeam: “133632”, idSoccerXML: “38”, idAPIfootball: “52”, intLoved: “0”, strTeam: “Crystal Palace”, …}
7 {idTeam: “133615”, idSoccerXML: “20”, idAPIfootball: “45”, intLoved: null, strTeam: “Everton”, …}
8 {idTeam: “133600”, idSoccerXML: “4”, idAPIfootball: “36”, intLoved: “1”, strTeam: “Fulham”, …}
9 {idTeam: “133635”, idSoccerXML: “42”, idAPIfootball: “63”, intLoved: null, strTeam: “Leeds”, …}
10 {idTeam: “133626”, idSoccerXML: “31”, idAPIfootball: “46”, intLoved: “1”, strTeam: “Leicester”, …}
11 {idTeam: “133602”, idSoccerXML: “6”, idAPIfootball: “40”, intLoved: “10”, strTeam: “Liverpool”, …}
12 {idTeam: “133613”, idSoccerXML: “18”, idAPIfootball: “50”, intLoved: “1”, strTeam: “Manchester City”, …}
13 {idTeam: “133612”, idSoccerXML: “17”, idAPIfootball: “33”, intLoved: “14”, strTeam: “Manchester United”, …}
14 {idTeam: “134777”, idSoccerXML: “8”, idAPIfootball: “34”, intLoved: “2”, strTeam: “Newcastle”, …}
15 {idTeam: “133720”, idSoccerXML: “35”, idAPIfootball: “65”, intLoved: “2”, strTeam: “Nottingham Forest”, …}
16 {idTeam: “134778”, idSoccerXML: “41”, idAPIfootball: “41”, intLoved: “1”, strTeam: “Southampton”, …}
17 {idTeam: “133616”, idSoccerXML: “21”, idAPIfootball: “47”, intLoved: “7”, strTeam: “Tottenham”, …}
18 {idTeam: “133636”, idSoccerXML: “43”, idAPIfootball: “48”, intLoved: “2”, strTeam: “West Ham”, …}
19 {idTeam: “133599”, idSoccerXML: “3”, idAPIfootball: “39”, intLoved: null, strTeam: “Wolves”, …}

headers: Object

access-control-allow-origin: “*”

alt-svc: “h3=”:443"; ma=86400, h3-29=":443"; ma=86400"

cf-cache-status: “DYNAMIC”

cf-ray: “7b18940e2a4fbc01-FRA”

connection: “close”

content-type: “application/json; charset=utf-8”

date: “Sun, 02 Apr 2023 11:02:13 GMT”

nel: “{“success_fraction”:0,“report_to”:“cf-nel”,“max_age”:604800}”

report-to: "{“endpoints”:[{“url”:“https:\/\/a.nel.cloudflare.com\/report\/v3?s=HLBGSH1zLD5vPgZ1jWWGpvxCGIQ40%2FslI3mCeqekUyycdgJSWVDv7i9k7cQba42YQC4QUhs…”

server: “cloudflare”

transfer-encoding: “chunked”

vary: “Accept-Encoding”

x-powered-by: “PHP/7.4.33, ASP.NET

status: 200’

detail response headers and 1 row of data:

'{
“api_list_teams”: {
“status”: 200,
“headers”: {
“date”: “Sun, 02 Apr 2023 11:02:13 GMT”,
“content-type”: “application/json; charset=utf-8”,
“transfer-encoding”: “chunked”,
“connection”: “close”,
“vary”: “Accept-Encoding”,
“x-powered-by”: “PHP/7.4.33, ASP.NET”,
“access-control-allow-origin”: “*”,
“cf-cache-status”: “DYNAMIC”,
“report-to”: “{“endpoints”:[{“url”:“https:\/\/a.nel.cloudflare.com\/report\/v3?s=HLBGSH1zLD5vPgZ1jWWGpvxCGIQ40%2FslI3mCeqekUyycdgJSWVDv7i9k7cQba42YQC4QUhslmjAjxj6vkdXlwgmxSbhWpqgiAPKawo62dJ3UePxp%2BTwjncQNcGET51Vv4OE4SMsy”}],“group”:“cf-nel”,“max_age”:604800}”,
“nel”: “{“success_fraction”:0,“report_to”:“cf-nel”,“max_age”:604800}”,
“server”: “cloudflare”,
“cf-ray”: “7b18940e2a4fbc01-FRA”,
“alt-svc”: “h3=”:443"; ma=86400, h3-29=":443"; ma=86400"
},
“data”: {
“teams”: [
{
“idTeam”: “133604”,
“idSoccerXML”: “9”,
“idAPIfootball”: “42”,
“intLoved”: “8”,
“strTeam”: “Arsenal”,
“strTeamShort”: “ARS”,
“strAlternate”: “Arsenal Football Club, AFC, Arsenal FC”,
“intFormedYear”: “1892”,
“strSport”: “Soccer”,
“strLeague”: “English Premier League”,
“idLeague”: “4328”,
“strLeague2”: “FA Cup”,
“idLeague2”: “4482”,
“strLeague3”: “EFL Cup”,
“idLeague3”: “4570”,
“strLeague4”: “”,
“idLeague4”: null,
“strLeague5”: “”,
“idLeague5”: null,
“strLeague6”: “”,
“idLeague6”: null,
“strLeague7”: “”,
“idLeague7”: null,
“strDivision”: null,
“strManager”: “”,
“strStadium”: “Emirates Stadium”,
“strKeywords”: “Gunners, Gooners”,
“strRSS”: “https://www.allarsenal.com/feed/”,
“strStadiumThumb”: “https://www.thesportsdb.com/images/media/team/stadium/w1anwa1588432105.jpg”,
“strStadiumDescription”: “The Emirates Stadium (known as Ashburton Grove prior to sponsorship, and as Arsenal Stadium for UEFA competitions) is a football stadium in Holloway, London, England, and the home of Arsenal. With a capacity of 60,704 it is the fourth-largest football stadium in England after Wembley Stadium, Old Trafford and Tottenham Hotspur Stadium.\r\n\r\nIn 1997, Arsenal explored the possibility of relocating to a new stadium, having been denied planning permission by Islington Council to expand its home stadium, Highbury. After considering various options (including purchasing Wembley Stadium), the club bought an industrial and waste disposal estate in Ashburton Grove in 2000. A year later, they received the council’s approval to build a stadium on the site; manager Arsène Wenger described this as the “biggest decision in Arsenal’s history” since the board appointed Herbert Chapman. Relocation began in 2002, but financial difficulties delayed work until February 2004. Emirates was later announced as the main sponsor for the stadium. The entire stadium project was completed in 2006 at a cost of £390 million. The club’s former stadium was redeveloped as Highbury Square, an apartment complex.\r\n\r\nThe stadium has undergone a process of “Arsenalisation” since 2009 with the aim of restoring Arsenal’s heritage and history. The stadium has hosted international fixtures and music concerts.”,
“strStadiumLocation”: “Holloway, London, England”,
“intStadiumCapacity”: “60338”,
“strWebsite”: “www.arsenal.com”,
“strFacebook”: “www.facebook.com/Arsenal”,
“strTwitter”: “twitter.com/arsenal”,
“strInstagram”: “instagram.com/arsenal”,
“strDescriptionEN”: "Arsenal Football Club is a professional football club ’

Sorry i don’t understand what you mean with your last post.
Do you have a live link where i can check your page?

Teodor , the problem is bigger. In my app now , any page that i link it with a server action DB, Api , isa not display the data in the front end. I can normally bind the schema , i can get the fields but no data. I check it with multiply server connections. Any idea. My app is running in local mode with sql lite.

So … did you check this doc i linked to?

and if yes - what do you see in the dev tools?

We need the server action status and response… please follow the doc!

Teodor i kill the project i reuse the database and i export the actions and the front end screens. Now everything is working in the new project. Seems like a service was not working correctly in the previous project. Thanks