https://github.com/opensource-direct/react-native-axios
React Native Axios Consume API by HTTP Protocol
https://github.com/opensource-direct/react-native-axios
api axios http react-native
Last synced: about 1 year ago
JSON representation
React Native Axios Consume API by HTTP Protocol
- Host: GitHub
- URL: https://github.com/opensource-direct/react-native-axios
- Owner: opensource-direct
- Created: 2023-03-29T05:02:08.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-29T07:45:21.000Z (about 3 years ago)
- Last Synced: 2025-01-30T03:45:35.684Z (about 1 year ago)
- Topics: api, axios, http, react-native
- Language: Java
- Homepage:
- Size: 394 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## react-native-axios
React Native Axios Consume API by HTTP Protocol
## Get Data News API in Console Log
Untuk fetch data dari API kita Perlu Menginstallkan `Axios`
```shell
~/Desktop/react-native/ReactNativeAxios ⌚ 11:50:48
$ npm install axios
```

kemudian pada App.tsx rename menjadi App.js, lalu ubah isinya seperti tampak pada kodingan dibawah ini
```js
import { StyleSheet, Text, View } from 'react-native'
import React, { useEffect } from 'react'
import axios from 'axios'
export default function App() {
console.info('Ini coba ambil data');
const getData = async () => {
try {
const res = await axios.get('https://newsapi.org/v2/top-headlines', {
params: {
country: 'id',
category: 'technology',
apiKey: '87d43d69278f492783fddbd07988ad8b'
}
})
console.info('Get Data New : ', res)
} catch (error) {
console.error(error.message)
}
};
useEffect(() => {
getData()
}, [])
return (
App
)
}
const styles = StyleSheet.create({})
```
running kemudian coba debug aplikasi, akses log pada `React Native Debugger` inspect element kemudian arahkan ke bagian `console`

Preferensi Library yang Diinstallkan
- [x] https://www.npmjs.com/package/axios