Noe Duran
Noe Duran

Reputation: 77

How to set count of JSON data from API to allow that many on a list?

export default class FutureLaunches extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      isLoading: true,
      dataSource: null
    };
  }

  componentDidMount() {
    return fetch("https://launchlibrary.net/1.4/launch")
      .then(response => response.json())
      .then(responseJson => {
        this.setState({
          isLoading: false,
          dataSource: responseJson.launches
        });
      })
      .catch(error => {
        console.log(error);
      });
  }

  render() {
    if (this.state.isLoading) {
      return (
        <View style={styles.container}>
          <ActivityIndicator />
        </View>
      );
    } else {
      let launches = this.state.dataSource.map((val, key) => {
        return (
          <View key={key}>
            <Text style={styles.name}>{val.name}</Text>
            <Text>{val.net}</Text>
            <Text>{val.windowstart}</Text>
            <Text>{val.windowend}</Text>
            <Text>{val.count}</Text>
          </View>
        );
      });

      return (
        <View style={styles.container}>
          <ScrollView contentContainerStyle={styles.contentContainer}>
            {launches}
          </ScrollView>
        </View>
      );
    }
  }
}

});

The total in the JSON is higher than the count, the count displays the amount of data sets on the page. How can I be able to change the count that's on the JSON so it could allow all the data sets from https://launchlibrary.net/1.4/launch, in this case 183 data sets are available.

Upvotes: 0

Views: 135

Answers (1)

Jan Wendland
Jan Wendland

Reputation: 1440

According to documentation, there is a limit parameter that controls the page size. Setting that parameter in the URL to -1 returns all results:

https://launchlibrary.net/1.4/launch?limit=-1

Upvotes: 2

Related Questions