Jump to content


Displaying Multiple Warships in a list

javascript api react-native wows

  • Please log in to reply
1 reply to this topic

Dimitri_Petrenko_00 #1 Posted 21 May 2019 - 02:05 PM

    Private

  • Player
  • 3897 battles
  • 15
  • Member since:
    02-19-2013

Hello!

 

I'm currently making a React-Native application, using Wargaming.net's API, named WarshipsApp. With this app, I want to be able to first display a list of ships from WOWS (fetched with the API) after a nation and ship class have been selected, and whenever the player taps on the ship name, it displays a list of the ship's parameters (also fetched from the API).

 

Now, I'm struggling to fetch certain fields, because from the 'data' array inside the API response, it displays different arrays in numbers, and I can't quite figure out how to get past that in my JavaScript file. 

 

Here's a simple example of the API-response:

Block Quote

{

"status": "ok",
    "meta": {
    "count": 100,
    "page_total": 4,
    "total": 350,
    "limit": 100,
    "page": 1
},
"data": {
    "3315513040": {
          "name": "[Zao]",
          "nation": "japan"
     },

}

 

 

And here is the code for the API response: 

Block Quote

const response = awaitfetch('https://api.worldofw...application_id=[app_id]&language=en&type=' + Class1 + '&limit=30&nation=' + nation);

const data = awaitresponse.json();

 

 

I can for example fetch the entire list of data with 'data.data', but I want to fetch only certain parts of the data, only the names basically.

But I can't work past the ship's ID, since it's the name of the entire sub-array.

 

If anybody knows a solution, I'd be glad to know it!


Edited by Dimitri_Petrenko_00, 21 May 2019 - 09:02 PM.


Hyster #2 Posted 22 May 2019 - 02:53 PM

    Warrant Officer

  • Player
  • 27454 battles
  • 595
  • [T-S_K] T-S_K
  • Member since:
    02-14-2012

i used to pull every thing, store in a mysql database then use sql to pull what i needed.

but that was for a website, how ud do it for an app i dt know but u need to figure out how to store data and how to manipulate it locally. 


Edited by Hyster, 22 May 2019 - 03:03 PM.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users