i try different tutorials but didn't solve my problemEste es mi código donde me quedé atascado
const [data, setData] = useState([]) useEffect(() => { getData() }, []) const getData = async () => { fetch(`my Api`,{ method: 'post', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } } ) .then((response) => response.json()) .then((responseJson) => { setData(responseJson.result); console.log("log for Health professionals =====>", responseJson.result) console.log("current_page at:::: =====>", responseJson.result.current_page) }) .catch((error) => { console.error(error); }); } const renderItem = ({item }) => { return( <View style={styles.itemRow} > <Text style={{fontSize:20}}>{item.current_page}</Text> <Text style={{fontSize:40}}>{item.result.current_page}</Text> </View> ) } return ( <FlatList style={styles.container} data={data} renderItem={renderItem} keyExtractor={(item, index)=>index.toString()} /> ) }; Intento imprimir datos desde mi consola. datos que obtengo de la API y quiero que esta respuesta se imprima en forma de paginación, pero no mostró ningún resultado en la pantalla de mi móvil. Intento resolver el problema a partir de documentación diferente pero no encuentro nada.
Solo quiero hacer un poco de paginación con esta respuesta api en reaccionar nativo
Según su respuesta, está pasando la clave incorrecta a la lista plana, intente debajo del código
const getData = async () => { fetch(`my Api`,{ method: 'post', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' } } ) .then((response) => response.json()) .then((responseJson) => { setData([...data, ... responseJson.data]); }) .catch((error) => { console.error(error); }); } return ( <FlatList style={styles.container} data={data} renderItem={renderItem} keyExtractor={(item, index)=>index.toString()} /> ) const renderItem = ({item }) => { return( <View style={styles.itemRow} > <Text style={{fontSize:20}}>{item.publisher}</Text> <Text style={{fontSize:40}}>{item.short_description}</Text> </View> ) }