Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
How to catch Laravel errors using capacitor http plugin

I have some validations in Laravel. When using axios I used .catch() to get those errors. Due to some cors issues, I started to use @capacitor-community/http library as an alternative to axios in order to handle http requests on mobile. But I have no idea how to catch validation errors and other errors coming from Laravel through this plugin. I have attached my code below,

This is the validation part of my Laravel code

$request->validate([
   'username' => 'required | string',
   'email'    => 'required | email | unique:users,email',
   'password' => 'required | string | confirmed | min:8',
]

This is my vue code,

<script setup>
...
import { Http } from "@capacitor-community/http";

const registerUser = async () => {
  loadingState.value = true;
  const options = {
    url: `${requestURL.value}/register_app_user`,
    headers: { "Content-Type": "application/json" },
    data: userForm,
  };

  const response = await Http.request({ ...options, method: "POST" });
};

</script>

I'm receiving HTML content without receiving any errors. Really appreciate it if somebody could help thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

By including ,

headers: { Accept: "application/json", "Content-Type": "application/json" },

It worked

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!