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.

React-native vs Ionic

React-native Introduction:- React Native is a robust hybrid or cross-platform development framework that enables the empowerment of React code with native platform capabilities. It runs as a background process on a user's device and interacts with the device's native components via bridging. Platform's key purpose is to build an app as close to native as possible while utilizing a majority of the same codebase for different platforms: Android and iOS. React knowledge is mandatory to build a React Native app. Also, the development of some specific functionality requires the usage of native code (Java or Kotlin for Android, Swift, or Objective C for iOS). However, this is rather rare, and in most cases, React Native knowledge is enough to launch an app.  Advantages of React Native Uses JavaScript regardless of the platform . React Native allows you to write code in JavaScript – the world's most popular programming language. Also, you can use native modules in Objective-C,...