How to call the laravel api in my Ionic Vue? I can build apk of that but the api wasn't call

import { createApp } from ‘vue’;

import { IonicVue } from ‘@ionic/vue’;

import App from ‘./App.vue’;

import router from ‘./router’;

import VueSweetalert2 from ‘vue-sweetalert2’

import ‘sweetalert2/dist/sweetalert2.min.css’

import ‘@ionic/vue/css/core.css’;

import ‘@ionic/vue/css/normalize.css’;

import ‘@ionic/vue/css/structure.css’;

import ‘@ionic/vue/css/typography.css’;

import ‘@ionic/vue/css/padding.css’;

import ‘@ionic/vue/css/float-elements.css’;

import ‘@ionic/vue/css/text-alignment.css’;

import ‘@ionic/vue/css/text-transformation.css’;

import ‘@ionic/vue/css/flex-utils.css’;

import ‘@ionic/vue/css/display.css’;

import ‘./theme/variables.css’;

import axios from ‘axios’;

import ‘swiper/swiper-bundle.css’;

const mobileToken = localStorage.getItem(‘mobileToken’);

axios.defaults.baseURL = ‘http://bookbubblesonline.infinityfreeapp.com/api’;

axios.defaults.headers[‘Authorization’] = Bearer ${mobileToken};

const app = createApp(App)

.use(IonicVue)

.use(router)

.use(VueSweetalert2);

router.isReady().then(() => {

app.mount(‘#app’);

});

axios.defaults.baseURL = ‘http://bookbubblesonline.infinityfreeapp.com/api’;
This is my web hosting api and I cannot call that :frowning: help me guys

Great to see another Laravel and Vue user! You need to actually make a call with axios. It looks like you are just setting the defaults atm.

https://axios-http.com/docs/api_intro

axios also supports async/await too (that’s how I use it).

I’m using Ionic Framework Vue sir, I have also hosting url for laravel http://bookbubblesonline.infinityfreeapp.com/api

I want to call that url to my ionic vue but if I change my app.js which is

axios.defaults.baseURL = ‘http://bookbubblesonline.infinityfreeapp.com/api’;
axios.defaults.headers[‘Authorization’] = Bearer ${mobileToken};

that url will not functioning during deployment or apk.

Help me sir ! :frowning:

You need to give a little more info. Are you getting any errors? Have you looked in DevTools to see if the request is even being made? Could be a CORS issue if you haven’t allowed the app url in your Laravel app (cors.php).

Are you not using HTTPS? It is highly recommended in 2023. If you aren’t, you will need to allow clear text (at least on Android). See Unable to carryout HTTP post on Android - #2 by twestrick