Category : axios

Vue console error log Am getting this 422 (Unprocessable Entity) error while trying to do a POST request using Laravel and Vue-resource. I currently have the following codes: register() { this.loading = true; this.axios.post(‘register’, { firstname: this.firstname, lastname: this.lastname, email: this.email, password: this.password, password_confirmation: this.password_confirmation }) .then(response => { this.loading = false; this.name = ”; ..

Read more

I want to build a client application based on Vue CLI using Axios to make requests to my API backend build with Laravel using the Sanctum Package in order to authorize requests. The error I receive is the following: Access to XMLHttpRequest at ‘http://api.webgame.test/register’ from origin ‘http://webgame.test:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ ..

Read more

template <template> <Toggle v-model:state="isReleased" @click="changeState"/> </template> script <script setup> import Toggle from "@/Components/CustomComponents/ToggleSwitch"; import { computed } from "@vue/reactivity"; import { Inertia } from "@inertiajs/inertia"; import { useForm } from "@inertiajs/inertia-vue3"; import {ref} from "vue"; let props = defineProps({ bundle: { type: Object, required: true, }, }); const isReleased = ref(props.bundle.released) function changeState(){ isReleased.value = ..

Read more

I am trying to update my user Profile but am not getting the request which was sent to Laravel from Nuxt, Pls guys help me, what did i do wrong here? Here is UpdateProfile.vue <!– HIDDEN INPUT –> <input type="file" id="file" @change="handleFileUpload($event)" /> <v-text-field v-model="currentUser.email" label="Email" :rules="[required(’email’), emailFormat()]" /> <v-text-field v-model="currentUser.password" label="Password" :type="showPassword ? ‘text’ ..

Read more

I just installed this https://github.com/laravel/breeze-next repository and as expected everything works fine as documented. Login, Logout and registration work fine. Now after login, I want to protect the API routes, but it throws errors as 401 when I try to access the protected route even after login. Here is AXIOS setup as given in Repo, ..

Read more

This is more of a general question regarding speeds for laravel/apis I’ve got a vue component that is a selector(vue-multiselect) that uses a GET request(via axios). This goes to my laravel backend api and gets all the users. return response()->json([‘customers’ => Customer::all()]); However there are currently a lot of records, 50,000 ish to begin with. ..

Read more

Laravel controller API returning "page not found" while consuming it from Axios in Next.js But everything is working fine in PostMan with the following code Controller function: public function viewsnippets(Request $request){ $slug = $request->slug; $postdata = Constant_model::getDataOneColumn(‘snippets’,"url_slug",$slug); if ($postdata->count() < 1) { $data[‘status’] = 404; $data[‘title’] = ‘Page Not Found’; $data[‘description’] = ‘Page Not Found’; ..

Read more

I am sending dynamic db name over request header and using middleware i am changing db name. but after login other request return unautorize. please help me to solve this. thanks in advance. my middleware is Config::set(‘database.connections.mysql.database’, request()->header(‘db_name’)); DB::purge(‘mysql’); and my axios header is const apiCall = axios.create({ baseURL: process.env.VUE_APP_ENV_API_URL, timeout: 100000, headers: { ‘Content-Type’: ..

Read more

i am writing a simple user register using Laravel with a simple code public function register() { $this->validate(request(), [ ‘name’ => ‘required’, ’email’ => ‘required|email|unique:users’, ‘password’ => ‘required’ ]); $user = User::create(request([‘name’, ’email’, ‘password’])); auth()->login($user); return [ ‘status’ => true, ‘user’ => $user ]; } then i am sending the data form Next.Js : using ..

Read more

I need to disable the background while the sweetalert(popup alert) that nothing should happen when user click anywhere else except the "OK" button Please help me to find out the solution. .then(function () { // always executed // Hide loading indication submitButton.removeAttribute(‘data-kt-indicator’); // Enable button => disabled ——******* submitButton.disabled = true; }); Sourc..

Read more

Presently, I pass data from Laravel to Vue (via MySQL DB’s) this way: In routes/web.php: Route::get(‘/’, [MyController::class, ‘index’]); In app/Http/Controllers/MyController.php public function index() { $results = Data::all(); return view(‘index’, compact(‘results’)); } In resources/views/index.blade.php: <div id="app"> <index-component :results="{{ $results }}" /> </div> And then in IndexComponent.vue props: { results: { type: Object } } This works ..

Read more

The information which I got by my previous question Vuex + Laravel. Why axios sends any values but only not that one, which come's with method's parameter? works only for situation when I pass only one argument in axios. I also found how to successfully pass multiple files with one argument, but in my situation, ..

Read more

I have an action method in my vuex store, which has two parameters with names "context", "payload". Payload has data and that vuex action method by itself sees and with console.log() prints in console the data, which comes with that payload parameter, but when I try to send that value with axios to controller, the ..

Read more

I’m trying to get data from a database through this ajax request: axios.get(‘/about-info’) web.php: Route::get(‘/about-info’, [CMSController::class, ‘aboutInfo’]); CMSController.php: public function aboutInfo() { $data = DB::table(‘about_info’)->first(‘order by id desc’); return $data; } but instead I am getting the whole welcome.blade.php content. It looks like the url in web.php is not called and instead a redirect happens. ..

Read more

I am trying to get data from this url: axios.get(‘/join-us-donate’) It SHOULD be sent through web.php: Route::get(‘/join-us-donate’, [CMSController::class, ‘joinUsDonate’]); and run this function from CMSController.php: public function joinUsDonate() { $data = DB::table(‘table’)->first(‘order by id desc’); return $data; } but it doesn’t. Instead axios.get returns the whole welcome.blade of my laravel project, which is confusing since ..

Read more