Skip to main content

How to use Axios In React-native

 


Axios Is used For Api Calling in React-native ...


Step 1. npm install axios;

After installing package.

import axios from "axios";

const options = {
        method:method   // post or get
        headers:{'content-type':'application/json'},
        data:data,
        url:"Apiurl",
    };

    axios(options).then(res => {
            //Do something
    }


Note If u Want to Send Form-data then 
change Content-type to multiformdata
and pass formdata in data field in Options

Comments

Popular posts from this blog

Push-Notification in React-native

Implimenting Push-notification in React-native Note: To send push notification you have to implement firebase first for implementing firebase check my previour blog 1. Install Package =  @react-native-firebase/messaging, 2.FcmService.js                                                                                           import   messaging   from   '@react-native-firebase/messaging' ; import  { Platform }  from   'react-native' ; class   FCMService  {     register  = ( onRegister ,  onNotification ,  onOpenNotification )  => {         this . checkPermission ( onRegister )         this . createNoti...

Disadvantages or Drawbacks of React-native

Despite its maturity, React Native still lacks some components. Others, in turn, are underdeveloped. The chances are you won’t have a problem with that, as the majority of custom modules you need are available, well-documented, and working properly. However, it might happen that you will have to build your solution from scratch or try to hack an existing one. When developing your custom modules, you could end up with three codebases (RN, Android, and iOS) for a component instead of only one. In each of those codebases, there can be differences in behaviour and appearance. Fortunately, those situations don’t come about often.