The pagination in Laravel Vue is causing a validation error due to an invalid prop type check failing

Recently, I delved into working with Nuxt.js and decided to install the Laravel-Vue-Pagination plugin. However, I encountered an error message in my console system that reads:

[Vue warn]: Invalid prop: type check failed for prop "data". Expected Object, got Array 

Here is a snippet of my code causing the issue:

getResults (page = 0) {
  this.$axios.$get('mydomain.com/api/Customer/loadCustomers/' + page).then((response) => {
    this.laravelData = response.data
  })
},

Below is how I structured my data:

data () {
return {
  laravelData: {},
  formFields: {},
  search: null,
  editMode: true,
  customerId: null,
  refresh: false
}
}

Here's the HTML code snippet where I use the pagination component:

<pagination :data="laravelData" @pagination-change-page="getResults" />

I made sure to register the components by using this import statement:

import Vue from 'vue'
Vue.component('pagination', require('laravel-vue-pagination'))

Additionally, here is a glimpse of the JSON feedback I received:

{
"success": false,
"total": 6,
"per_page": 10,
"current_page": 0,
"last_page": 1,
"data": [
    {
        "id": "34",
        "customer_name": "Philippe Lesen",
        "customer_company_name": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfbbb0a7a6bbb6a8beafb09fb2beb6b3b6b1beabb0adf1bcb0b2">[email protected]</a>",
        "customer_email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="771a02040e151214160716371a161e1b1e191603180559191203">[email protected]</a>",
        "customer_phone": "+4382251059",
        "customer_fax": "+1 (223) 134-7141",
        "customer_mobile": "+4382251059",
        "customer_website": "https://www.qusopywode.org.au",
        "customer_type": "2",
        "billing_address": "Cupiditate alias asp",
        "billing_city": "Delectus reprehende",
        "billing_state": "In velit illo ut vol",
        "billing_zip": "73660",
        "billing_country": "TH",
        "shippingaddr_id": null,
        "currency": "EUR",
        "sales_representative": null,
        "payment_condition": null,
        "payment_method": null,
        "tax_preference": "1",
        "invoice_notification": "1",
        "note": null,
        "status": null
     }
]
 }

Answer №1

The problem was resolved by implementing this.laravelData = response

Answer №2

The issue has been resolved, thanks to your efforts.

In your code, you initially declare the variable laravelData as an object:

 laravelData: {},

However, later on, you assign it to an array:

this.laravelData = response.data

resulting in a potential mismatch of data types.

"data": [

To rectify this, consider declaring laravalData as an array instead.

 laravelData: [],

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling to locate __proto__ of the global object known as "window."

Currently I am using Google Chrome browser. console.log(window.__proto__.__proto__.__proto__); console.log(window.__proto__.__proto__.__proto__ === EventTarget.prototype); The first code mentioned above returns EventTarget.prototype for me. This can be ...

Discovering the magic of Vue SCRIPT SETUP

I have successfully implemented the simple-vue-camera library and it works well, but I would like to utilize it with script setup. However, I am unable to access the snapshot method of the camera... The issue seems to be in the 'const cameraComponent ...

Learn how to automatically set the checked state of a radio button by toggling another radio button

I have two sets of radio buttons, each with four options. The first set has no default selection (unchecked) using jQuery, while the second set has the first option checked by default. What I'm looking to achieve is that when a radio button in the f ...

Vue.js: Error 404 - POST request endpoint not found

My goal is to access my Quasar application from other devices connected to the Local Area Network. I have successfully run the app on these devices, but I encountered an error POST http://10.0.0.20:8080/MyComposer/?submitId=3 404 (Not Found) when trying to ...

JavaScript: Adjust DIV Width Based on Window Height

Is there a way to make the width of a div equal to the height of the window in jquery? I attempted this method: <script type="text/javascript"> $(".rt-container").style.width = $(window).height(); </script> Unfortunately, it did not work. I ...

Pulling information from an iOS application to a MEVN application using a GET request

After successfully building a Vue.js Single Page Application with an Express/Node backend, I am now venturing into creating an iOS app that can interact with the same backend. When attempting to make POST requests from iOS (Xcode) to log in a user using A ...

Having difficulty combining an array of JSON responses

I am working on an API call where I need to merge two objects and return them as a single entity. router.get('/reviewsavg', async (req, res) => { try { //enitityId[] is an array consisting of ID's to look up form const p ...

The method JSON.stringify is not properly converting the entire object to a string

JSON.stringify(this.workout) is not properly stringifying the entire object. The workout variable is an instance of the Workout class, defined as follows: export class Workout { id: string; name: string; exercises: Exercise[]; routine: Ro ...

Choose a country from a modal in a React application

click here for image description I need help implementing the screenshot above. My goal is to change the default country name and flag when a user clicks on the country dropdown menu. I have been using headless UI so far, but I'm struggling to figure ...

Determine the distinct elements in an array using JavaScript/jQuery

I have incorporated Gridster widgets into my webpage, each with a button that turns the widget's color to red when clicked. Upon clicking the button, the parent element is also added to an array. My main goal I aim to have the parent element added t ...

Show data from a Node.js server in its original format within an AngularJS application

Currently, I am using the angular fullstack generator to develop a web application. One issue I am facing is sending file data from the Node.js server to display on the front end. The problem arises because the data is being sent in an unformatted manner, ...

Unable to use model.find() in post findOneAndUpdate hook for Mongoose

Introduction In Mongoose, I am facing an issue with a post findOneAndUpdate hook where I need to perform a database query. Specifically, when trying to execute a .find() operation on another model, I encounter the following error: Error Description Typ ...

When the canvasJS range column chart is below the horizontal axis, modify the color and width of the bars

For each day of the week, there are records of fuel consumed and refilled. I envisioned representing this data in a range column chart using CanvasJS library. The unique aspect is that the color and width of the bars should change dynamically based on thei ...

Sending JavaScript array to PHP server-side script

In my current Web application project, I am faced with the task of working with two different lists. To achieve this, I need to convert the list into an array and then pass this array from JavaScript to PHP for further analysis. Below is a simplified exam ...

What is the process for changing the text in a text box when the tab key on the keyboard is pressed in

When a user types a name in this text box, it should be converted to a specific pattern. For example, if the user types Text@1, I want to print $[Text@1] instead of Text@1$[Text@1]. I have tried using the keyboard tab button with e.keyCode===9 and [\t ...

The <v-select> component in VueJS fails to bind properly during a post operation

Currently, I am in the process of developing an asp.net mvc application that utilizes VueJS on the front end. While working with a variety of forms, I have encountered an issue where text fields function properly when submitting the form; however, this is ...

Unable to impose a restriction on the number input field limit

My input field has a type of "number" with the min and max attributes applied to limit user input. However, I am facing an issue where users can still enter values beyond the set limit. How can I prevent users from entering values above the specified lim ...

Adjusting column widths in Material-Table: A guide to resizing columns

I am currently using the Material Table library, recommended by Google Material UI as a top data table library. I am facing some issues related to configuring the width of columns in this library. The column's `width` property seems to be functioning ...

webpack encountered an issue: The configuration.module contains an unidentified property 'loaders'

Upon starting the server with npm run start, I encountered the following error message: ✖ 「wds」: Invalid configuration object. Webpack has been initialized using a configuration object that does not comply with the API schema. - Configuration cont ...

Click to shift the div downwards

Currently, I have a piece of javascript applied to a div that directs the user to a specific link: <div style="cursor:pointer;" onclick="location.href='http://www.test.com';"> I am wondering if there is a way to add an effect where, upon ...