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 . createNotificationListeners ( onRegister ,  onNotification ,  onOpenNotification )    }     registerAppWithFCM  =  async ()  =>  {         if ( Platform . OS  ===  'ios' ){          await   messaging (). registerDeviceForRemoteMessages ();          await   messaging . setAutoInitEnabled ( true )        }           }     checkPermission  = ( onRegister )  =>  {       

React Native or Flutter?

1.Flutter was harder to learn than React Native.      Mainly because React Native uses JavaScript (which is a familiar language for me) whereas I was new to Dart – the language used by Flutter. So,  if you are new to Dart and trying to learn Flutter, it will take more time than learning React Native . But the opposite is also true – if you have experience in Dart, then learning Flutter will be a walk in a park. 2. performance:=> Flutter has the upper hand as it’s compiled to ARM or x86 native libraries, which makes it really fast.  React Native isn’t compiled to native code, and it still has the JavaScript layer, making it less performant than Flutter.   3. Bugs on React Native have also started to take a lot longer to get fixed.  The dashed border issue, for one; as well as a separate issue supporting various build flavours etc. Most companies running React Native in production, run a custom fork to fix bugs that aren’t fixed upstream. The Flutter devs are more proactive, and you c

Implement Firebase in React-Native

Welcome to React Native Firebase! To get started, you must first setup a Firebase project and install the "app" module. I  Installation Installing React Native Firebase requires a few steps; installing the NPM module, adding the Firebase config files & rebuilding your application. 1. Install via NPM Install the React Native Firebase "app" module to the root of your React Native project with NPM or Yarn: # Using npm npm install --save @react-native-firebase/app # Using Yarn yarn add @react-native-firebase/app The  @react-native-firebase/app  module must be installed before using any other Firebase service. 2. Android Setup To allow the Android app to securely connect to your Firebase project, a configuration file must be downloaded and added to your project. Generating Android credentials On the Firebase console, add a new Android application and enter your projects details. The "Android package name" must match your local projects package name w