Encountering a "Cannot read property 'protocol' of undefined" error when attempting to implement a search bar with Laravel and Vue JS using the Vuetify Framework

Currently, I am working on creating a search bar using Laravel and Vue JS with the Vuetify framework. Below are my controller functions:

/**
 * Retrieve names and references of all projects for the user.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */

public function getAllProjects()
{
    return Project::forClient()->get(['name','reference']);
}

/**
 * Search for projects based on query input.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */

public function searchForProject(Request $request)
{
    $query = $request->query('query');

    $projects = Project::where('name', 'like', '%' . $query . '%')
        ->orWhere('reference', 'like', '%' . $query . '%')
        ->get();

    return view('projects.edit', compact('projects'));
}

The search bar implementation in Vue is as follows:

        <v-autocomplete
        v-model="model"
        :items="getProjNames"
        :loading="isLoading"
        clearable
        hide-details
        @keyup.enter="queryForProjects()"
        item-text="name"
        item-value="symbol"
        solo
        >
            <template v-slot:no-data>
                <v-list-item>
                    <v-list-item-title>
                        Please search for a project
                    </v-list-item-title>
                </v-list-item>
            </template>
        </v-autocomplete>

Here are the relevant methods:

    getAllProjects() {
        var self = this;
        apiClient.get(window.routes["projects.getAllProjects"])
            .then(function (response) {
                console.log(response.data);
                self.projects = response.data;
            })
            .catch(function(error){
                console.error(error);
                if (!!error.response) console.log(error.response);
            });
    },

    queryForProjects() {
        var self = this;
        apiClient.post(window.routes["projects.searchForProject"], {query: this.model})
            .then(function (response) {
                console.log(response.data);
                self.projects = response.data;
            })
            .catch(function(error){
                console.error(error);
                if (!!error.response) console.log(error.response);
            });
    },

A computed value to list all projects has been defined:

computed: {
    getProjNames() {
        return this.projects.map(a => a.name);
    }
},

Despite my efforts, I am encountering an error indicating that there may be an issue with the request. Unfortunately, I am unsure about what exactly is going wrong:

https://i.stack.imgur.com/mpJTU.png

Answer №1

The issue you are encountering is due to a missing protocol attribute in your JavaScript code. It seems like the specific code causing this error has not been provided in the post.

To resolve this error, you should search for references such as request.protocol or meeting.protocol and ensure that the object (request or meeting) is correctly loaded and passed within the context of the code.

If you require further assistance, please share the portion of code where [something].protocol is referenced along with its complete context.

I hope this information proves helpful!

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

What is the best method for storing a third-party image in cache?

Running my website, I aim to achieve top-notch performance scores using LightHouse. I have successfully cached all the images I created (Cache-Control: public, max-age=31536000). Unfortunately, third-party website images are not cached. How can I cache t ...

The functionality of Highcharts-more.js is not functioning properly within a project set up using vue-cli

Recently, I have been working on a vue-cli project and attempting to create a polar chart similar to the one shown here: To achieve this, I needed to install and import the highcharts and highchart-more libraries using npm. However, upon importing both fi ...

When setting up Vue.js for unit testing, the default installation may show a message stating that

Recently set up a fresh Vue project on Windows 7 using the VueJS UI utility. Unit testing with Jest enabled and added babel to the mix. However, when running "npm test" in the command line, an error is returned stating 'Error: no test specified' ...

Leveraging Javascript Modules within a Typescript Vue Application

The issue at hand I've encountered a problem while attempting to integrate https://github.com/moonwave99/fretboard.js into my Vue project. My initial approach involved importing the module into a component as shown below: <template> <div&g ...

Managing "unprocessed information" in a Node.js environment and transferring the information through a Node Express endpoint

Currently, I am in the process of making an API call to retrieve a file using axios: async function fetchData() { const configuration = {}; // { responseType: 'stream'}; const { response } = await axios.get(URL, configuration); c ...

The system was unable to locate node.js with socket.io

I'm having trouble locating the file. According to the documentation I reviewed, socket.io is supposed to be automatically exposed. Encountered Error: polling-xhr.js?bd56:264 GET http://localhost:8081/socket.io/?EIO=3&transport=polling&t=LyY ...

Encountered a SyntaxError while deploying Nuxt.js SSR on Passenger: The import statement cannot be used outside a module

I am currently in the process of deploying my Nuxt app on a hosting service that uses Passenger to run Node.js applications. After building the app with the command ">npm run build" and deploying the content from the .nuxt folder onto the server, specif ...

Can anyone help with displaying a PNG image in Vue/Node/Express? I am struggling to show the image that I sent from a Node.js server to a Vue app client

In my Node/Express application, I've set up a route like this: app.get('/get-image', function(req, res) { ... res.sendFile(path.join(__dirname, '..', account.profileImg)); }) Now in my client-side Vue app, I'm tryi ...

NextJS is encountering an issue with Axios' withCredentials functionality

I'm facing an issue where Axios is not sending the cookie to my backend API, even though I have set the withCredentials properly. Front-end (NextJS): import axios from "axios" const BASE_URL = "http://localhost:8000" export defa ...

What are the steps to crawl and save content from multiple websites simultaneously?

My project involves creating a webpage that can crawl multiple other webpages and integrate the data. I am using node.js & vue.js for this purpose. By utilizing puppeteer & cheerio, I have successfully been able to crawl a single page and store its data i ...

Retrieve a formatted Word document from a C# endpoint to a Node.js server

I am currently facing an issue with my Node.js server that sends a GET request using axios to a C# endpoint with JSON as a parameter. The C# API then uses Newtonsoft.Json to deserialize the JSON, reads a Word file into memory, and inserts data. The final s ...

Upon executing npm install in my Laravel project, an error message promptly appears stating: "npm WARN deprecated [email protected]: gulp-util is deprecated - replace it."

Recently, I set up a brand new Laravel Project. After executing the command: php artisan preset vue, when I tried running npm install, an error occurred that stated: npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, followi ...

Where can Vue.js be found?

After dedicating an hour to watching instructional YouTube videos on Vue.js, I am still struggling to grasp the language! In the past, I have worked with Node.js, Jquery, and Mongodb to develop websites... I believe that web applications require multiple ...

Bypass SSL certification validation in Axios

Encountering an issue while calling the API. The error message "Error: unable to get local issuer certificate" is being displayed. To resolve this, I attempted to add a httpsAgent as shown below: var agent = new https.Agent({ rejectUnauthorized: false ...

Searching for files in directories and subdirectories using Node.js

Although I found this solution, it seems to be quite slow. I am looking for the quickest way to traverse directories without using npm packages. Any suggestions? ...

Utilizing Vue.js to connect with a Node.js server

After setting up a basic Node.js server, the following code is running successfully: var http = require('http'); var server = http.createServer(); server.on('request', function(req, res) { res.writeHead(200, { 'content ...

Node.js vulnerability labeled as CVE-2021-38628

Description: Enhance security measures by disabling the use of TLSv1.0 protocol and transitioning to a more secure option like TLSv1.2. To perform a manual test, utilize the following openssl commands: openssl s_client -connect ip:port -tls1. If succes ...

After the for loop, I must gain access to all the data from Axios

I have created a basic word combination website and I am facing an issue in getting all possible words in one string. Here is the code snippet that I have written: const fs=require('fs'); const axios=require('axios') function test(want) ...

Issue with installing Gulp using Laravel Homestead and Elixir

While attempting to run npm install in homestead, I encountered a lengthy list of errors that started with npm ERR! UNKNOWN, mkdir '/home/vagrant/Code/gulp/node_modules/gulp-imagemin/node_modules/imagemin/node_modules/imagemin-optipng/node_modules/o ...

Cookie authentication is effective for verifying users on a desktop platform, whereas it may not be as reliable

My backend is built with express.js and Sequelize, and the authentication route is as follows: exports.signin = (req, res) => { Admin.findOne({ where: { username: req.body.username } }) .then(admin => { ...