I need to get data in react-native app with axios. I can get data with simple GET method as below:
class AlbumList extends Component {
state = { albums: [] };
componentWillMount() {
//axios.get('https://rallycoding.herokuapp.com/api/music_albums') .then(response => console.log(response));
axios.get('http://rallycoding.herokuapp.com/api/music_albums')
.then(response => this.setState({ albums: response.data }));
}
renderAlbums() {
return this.state.albums.map(album =>
<AlbumDetail key={album.title} album={album} />);
// return this.state.albums.map(album => <Text>{album.title}</Text>);
}
render() {
console.log(this.state);
return (
<View>
{this.renderAlbums()}
</View>
);
}
}
How can i get data from API with POST
method and I also need to pass header and api-username,api-password, apitoken ?
I need something like https://stackoverflow.com/a/41358543/949003 but with AXIOS.
Edit:
I need to get data from LINNWORK API. if someone had done this please guide. They first need to authorize and then I can get data from there. So authrize and then next step.