Vue TypeError: Object(...) function not recognized

I am currently learning Vue and experimenting with form handling. I am developing a web application for managing meetings which includes a multi-step form to collect visitor and host data. However, upon clicking the submit button, I encounter the following error message:

TypeError: Object(...) is not a function
. Despite searching on stackoverflow, I haven't been able to find a clear solution. Here is the snippet of my code:

scheduleMeeting.js

<template>
    <el-container>
        <el-row>

            <el-col class="desc" :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
                <p>Your content here</p>
            </el-col>
          
			<!-- more HTML content here -->

            <el-col class="form-div" :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
				<!-- Form elements and steps -->
            </el-col>
        </el-row>
    </el-container>
</template>

<!-- Script section - method implementations -->

<!--<style lang="css"></style>-->

meeting.js

// Import necessary modules

export default {
    scheduleMeeting(meeting) {
        return session.post("/meeting/create/", {
            ...meeting
        })
    }
};

Below is the complete error log message:

Uncaught (in promise) TypeError: Object(...) is not a function
    at eval (ScheduleMeeting.vue?34e8:184)
eval    @   ScheduleMeeting.vue?34e8:184
Promise.then (async)        
createMeeting$  @   ScheduleMeeting.vue?34e8:182
tryCatch    @   vue-phone-number-inp…common.js?7bec:2629
invoke  @   vue-phone-number-inp…common.js?7bec:2855
prototype.<computed>    @   vue-phone-number-inp…common.js?7bec:2681
<!-- Error continuation details until the end -->

Any guidance or assistance regarding this error would be greatly appreciated!

Answer №1

Your issue stems from the way you are importing and exporting functions in your code. In your createMeeting method, you are calling scheduleMeeting without actually importing a function, but rather an object that contains the function.

The export from your meeting.js file looks like this:

import session from "./session";

export default {
    scheduleMeeting(meeting) {
        return session.post("/meeting/create/", {
            ...meeting
        })
    }
};

This setup exports an object that you then assign to scheduleMeeting in your import statement as follows:

import scheduleMeeting from "../api/meeting"

As a result, your actual function is located at scheduleMeeting.scheduleMeeting within your code.

To correct this, consider using a more standard ES6 approach by modifying your meeting.js file like so:

import session from "./session";

export function scheduleMeeting(meeting) {
    return session.post("/meeting/create/", {
        ...meeting
    })
}

And update your import statement accordingly:

import {scheduleMeeting} from "../api/meeting"

There are other ways to restructure your code to solve this problem, but this approach should offer clarity and consistency.

Answer №2

I ran into a similar issue recently when I overlooked using curly braces in an import statement for vuex. Instead of coding:

import mapGetters from 'vuex'

I had to correct it to the proper syntax:

import { mapGetters } from 'vuex'

After making this adjustment, everything worked smoothly.

Answer №3

I recently encountered an issue while attempting to create a unique identifier using the Quasar framework without enclosing it in curly braces.

import uid from 'quasar'

The problem was resolved when I included the curly braces:

import {uid} from 'quasar'

Answer №4

Not long ago, I encountered a similar issue and solved it by updating the vue-router version to "3.5.2". Everything is running smoothly now.

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

React: Issue encountered when updating props from parent component (Error executing removeChild operation)

Currently, I am utilizing react along with AJAX to retrieve data for a list. However, every time componentWillReceiveProps(nextProps) is triggered after the initial setup, an error occurs. This error typically arises when the URL for the AJAX call has chan ...

Having trouble getting jquery to filter json data based on the selected option

I have developed a code using jQuery to filter the options in a drop-down list based on the selection made. The data is in JSON format and is fetched from a database. However, when I select an option from the drop-down list, the code does not enter the loo ...

Ways to apply jquery.validate rules that have already been defined to form fields that are added dynamically

I need to duplicate a specific section of a form and apply the same validation rules that were set up before. After researching this issue, I found that most recommendations suggest adding new rules to the newly generated elements. Therefore, I attempted ...

I am unable to get JQuery UI Dialog to open on my end

Coding in HTML: <button type="button" class="btn btn-success" style="margin-bottom:14px" id="btnAdd" onclick="modaladdedit('URLToMyController')"><i class="fa fa-plus"> Add New</i></button> HEAD Tag Setup: <link rel=" ...

Incorporate an Event into a Vue.js JavaScript string within an HTML file

I am attempting to trigger the event in a JavaScript string. Within the buffer, I have called this event: @click.prevent = "Buy($event)" However, the browser is not interpreting it correctly: https://i.sstatic.net/uHs8W.jpg Here is the code snippet: ...

Attempting to employ the .reduce method on an object

Currently, I am faced with the task of summing a nested value for all objects within an object. The structure of my object is as follows: const json = [ { "other_sum": "1", "summary": { "calculations" ...

Create a collection of SVG illustrations using Vivus.js

Is it possible to draw multiple SVGs using Vivus.js without having to call the function for each individual drawing? I've encountered an issue with the second drawing not animating properly. Any suggestions or experience with this? Check out this pen ...

Tips for showing an Object with nested Objects in Vue.js

Looking for guidance on displaying a JSON object in Vue.js with the following structure: { "1": [ "15-16", "16-17", "17-18", "18-19" ], "2": [ & ...

Issues with Nuxt Authentication when deployed live

Attempting to deploy a nuxt application on a server with nginx acting as a proxy to localhost. Everything seems to be functioning properly; the application can be accessed using the server's domain and API calls can be made to the server. However, aut ...

The functionality of making Slim POST requests is currently not functioning as expected within the Ionic

An issue is arising with my app that makes calls to a REST API using POST and GET methods. The app I'm developing with Ionic works perfectly when emulated using the command: ionic serve --lab However, when running the app on an actual device, calls ...

Tips for preventing visual glitches caused by inaccurate world coordinates in WebGL

Issue: Encountering rendering glitches while using world coordinates in the fragment shader to display a grid. The grid does not move uniformly when the plane it is rendered on is moved, resulting in one "half" moving while the other remains idle. Refer ...

Exploring the functionality differences between mouse wheel tilt and scroll in JavaScript with scrollTop

Did you know that some computer mice come equipped with a scroll wheel that can tilt both left and right? This feature allows users to navigate through Google's piano roll app, which can be accessed here (source code available here). I am working to ...

Issues with Javascript functionality on aspdotnetstorefront site

Lately, I've been facing some challenges with my Javascript and jQuery codes when trying to implement them in the storefront. Despite attempting different methods to create a slider, none seem to work within the store environment - even though they fu ...

Issue encountered in Three.js while attempting to parse binary STL file: RangeError indicating out of bounds access problem

One of my main objectives is to import private STL files using three.js from a secure Laravel 8 storage directory. Unfortunately, the traditional method of using the .load function from STLLoader.js does not work in this scenario: const loader = new THREE ...

What are some ways I can incorporate modular constants into my Firebase Functions?

While working with Firebase functions, I've come across the option to organize functions into separate files for easier maintenance. You can find the documentation I used here. Currently, I'm exploring how to incorporate modular string constants ...

What are the methods for creating a diagonal line using GWT or the combination of HTML, CSS, and JavaScript?

I'm currently developing a web application that requires connecting elements with lines. I would prefer the lines to not be limited to just horizontal or vertical paths. Additionally, I need to be able to detect clicks on these lines. I've explor ...

What is the best way to make buttons trigger an action on a jQuery confirmation dialog?

Clicking on an image within the jQuery Dialog will open a confirmation dialog box prompting you to confirm if you want to delete. You can choose between Yes or No for confirmation. This functionality is implemented using three files: The main file index. ...

In Chrome, the `Jquery $('input[name=""]').change(function will not be triggered unless there is an unhandled error following it

Here is a script that I've created to make certain inputs dependent on the selection of a radio button. The 'parent' input in this case is determined by the radio button choice. Upon document load, the script initially hides parent divs of ...

Error: The property "id" cannot be destructured from req.params because it is not defined

I am attempting to retrieve a user profile from a database and return it as a JSON object when the profile URL (localhost:3000/Profile/1) is accessed. However, I am encountering an error: TypeError: Cannot destructure property id of req.params as it is un ...

Can Cesium "separate" intersecting polylines?

Currently, I am utilizing Cesium and aiming to visually display multiple polylines between two entities. Specifically, I want a green polyline from entity A to entity B, as well as a blue polyline from entity A to entity B. My intention is for these lines ...