Vue.JS has issued a warning indicating that the `util._extend` API is no longer supported. To address this, developers are advised to utilize Object

During the execution of a call API request, the Vue.JS application encountered an error. The API is hosted at Okta, and the request is successful when using cURL in the CLI.

Error Message

(node:82171) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
7:45:24 PM [vite] http proxy error:

ExternalAPI.vue

<template>
  <div>
    <div class="mb-5">
      <h1>External API</h1>
      <p>
        Call an external API by clicking the button below. This will call the
        external API using an access token, and the API will validate it using
        the API's audience value.
      </p>

      <button class="btn btn-primary mt-5" @click="callApi">Call API</button>
    </div>

    <div class="result-block-container">
      <div :class="['result-block', apiMessage ? 'show' : '']">
        <h6 class="muted">Result</h6>
        <highlightjs language="json" :code="JSON.stringify(apiMessage, null, 2) || ''" />
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { useAuth0 } from "@auth0/auth0-vue";
import { ref } from "vue";

export default {
  name: "api-view",
  setup() {
    const auth0 = useAuth0();
    const apiMessage = ref();

    return {
      apiMessage,
      async callApi() {
        // Get the access token from Auth0
        const accessToken = await auth0.getAccessTokenSilently();

        try {
          // Call the external API with the access token
          const response = await fetch("/api/external", {
            headers: {
              Authorization: `Bearer ${accessToken}`,
            },
          });

          // Parse the response as JSON
          const data = await response.json();

          // Store the API response in the apiMessage variable
          apiMessage.value = data;
        } catch (e: any) {
          // Handle any errors that occur during the API call
          apiMessage.value = `Error: the server responded with '${e.response.status}: ${e.response.statusText}'`;
        }
      },
    };
  },
};
</script>

Viteconfig.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    proxy: {
      '/api': 'http://localhost:3001',
    }
  },
  plugins: [vue()]
})

I attempted to update the npm packages and locate where the util.\_extend (API) is being used. This line is not found in any of the files, suggesting it may be within an imported library that I am utilizing.

When running the application with trace deprecation, it leads me to this

**NODE_OPTIONS=--trace-deprecation npm run serve**
(node:84741) [DEP0060] DeprecationWarning: The `util.\_extend` API is deprecated. Please use Object.assign() instead.
    at ProxyServer.<anonymous> (/Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:56939:26)
    at viteProxyMiddleware (/Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:57226:23)
    at call (/Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:44131:7)
    at next (/Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:44075:5)
    at cors (/Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:44599:7)
    at /Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:44635:17
    at originCallback (/Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:44625:15)
    at /Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:44630:13
    at optionsCallback (/Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:44610:9)
    at corsMiddleware (/Users/rami-dev/Documents/Pizza42Okta/02-Calling-an-API/node_modules/vite/dist/node/chunks/dep-0a035c79.js:44615:7)
8:03:38 PM [vite] http proxy error: AggregateError [ECONNREFUSED]:
    at internalConnectMultiple (node:net:1117:18)
    at afterConnectMultiple (node:net:1684:7)

Answer №1

It seems like the issue you're experiencing is related to Node.js. Have you considered downgrading to version 20 to see if that resolves the problem? Here's a helpful link: Node.js error.

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

Designing a popup using Angular, CSS, and Javascript that is capable of escaping the limitations of its parent div

I'm currently working on an Angular project that involves components nested within other components. My goal is to create a popup component that maintains the same size and position, regardless of where it's triggered from. One suggestion I rece ...

Discovering the value of a checkbox using jQuery and Ajax

I have a challenge with sending the state of multiple checkboxes on my page back to the database using ajax. While I am comfortable working with jquery and ajax for SELECT and OPTIONS elements, I am struggling to do the same for checkboxes and extracting t ...

Changing a button's text in Vue.js when holding a keyboard modifier - how to do it!

While working with Vue, I am attempting to modify a button's behavior when the Shift key is pressed. Adjusting the behavior of the click event was straightforward: @click.exact="goForward" @click.shift="goBackward" However, I am f ...

Encountering a problem where a new Laravel project fails to recognize Vite during the execution of either npm run dev or npm

After setting up a new Laravel project with 'version 10' using the command: composer create-project laravel/laravel example-app I proceeded to run: npm install npm ERR! Cannot destructure property 'name' of '.for' as it is ...

Troubleshooting the issue with mocking API and creating a regular expression to match the dynamic part of a URL

I am struggling to create a mock for an API that includes dynamic parts in the URL. I attempted to use a regular expression, but it is not functioning as expected. The URL I am trying to mock is: https://example.com/programs/2fcce6e3-07ec-49a9-9146-fb84fb ...

The issue of Heroku neglecting to clear or update the node_modules directory for a library hosted on GitHub

Our team is currently managing a node web project on Heroku which relies on a library hosted on GitHub. We frequently update this library on GitHub. However, when we push the revised node web project to Heroku for deployment, it appears that it does not v ...

What is the equivalent of getElementById in .ts when working with tags in .js?

Looking to incorporate Electron, Preload, Renderer with ReactJS and TypeScript into my project. <index.html> <body> <div id="root" /> <script src='./renderer.js'/> </body> <index.ts> const root = Re ...

Using the video-js feature to play multiple videos simultaneously

Is it possible to play multiple videos using video-js functionality simultaneously? The answer is yes! Check out Fiddle 1 However, an issue arises when wrapping a trigger, such as a button, around the function that invokes playVideo(). This causes the v ...

Error message: The requested resource could not be loaded due to a server error (status code 500) when using

I have been struggling to identify the exact issue with my code, despite referencing previous questions on the topic. function viewcalldetails(obj) { alert("clicked"); var id = $(obj).attr("id"); $(".style-t ...

Transforming Json data into an Object using Angular 6

https://i.stack.imgur.com/JKUpL.png This is the current format of data I am receiving from the server, but I would like it to be in the form of an Object. public getOrder(): Observable < ORDERS > { return this._http.get < ORDERS > (`${thi ...

Steps for adjusting the position of this div in relation to the main container

Apologies in advance for my lack of HTML skills. I am struggling with a page layout issue. I have a website at . When the window is resized, the ads div on the right side overlaps the main container. What I would like to achieve is to make this ads div re ...

What are the benefits of sticking with Express versus transitioning to a combination of JavaScript and HTML?

Recently, I've been developing a web application that involves taking user input to make modifications to files on the server side. The main logic for this project is built in node.js and operates via command line, with the rest of the site being deve ...

What is the best approach for managing validations on a field-by-field basis within a Formik FieldArray?

Scenario: When there are 3 participants, each participant will receive a set of questions. However, the display of each question is dependent on a list of "applied tickets" associated with the question. TLDR; I need to understand: if it's possible ...

Top solution for preventing text selection and image downloading exclusively on mobile devices

My plan is to use the following code to accomplish a specific goal: -webkit-touch-callout:none; -webkit-user-select:none; -khtml-user-select:none; -moz-user-select:none; -ms-user-select:none; user-select:none; -webkit-tap-highlight-color:rgba(0,0,0,0); I& ...

When incorporating <Suspense> in Next.js, the button's interaction was unexpectedly lost

'use client' import React, { Suspense } from "react"; const AsyncComponent = async () => { const data = await new Promise((r) => { setTimeout(() => { r('Detail'); }, 3000) }) as string; return <div>{d ...

The fetch request in a React application is not returning a response body, whereas the same request functions properly when made using Postman

My React app is successfully running locally with backend REST APIs also running locally. However, when I attempt to make a POST call to the REST API, the call goes through but the body appears to be empty. Below is a snippet of the sample code: const bod ...

Leveraging flot in conjunction with NPM, React, and Node

I've been attempting to utilize flot in a Node.js React project, but I'm running into issues with the import. The browser console is showing the error: Uncaught TypeError: _jquery2.default.plot is not a function This error is essentially the sa ...

How can one check in JavaScript if a specific URL was targeted with a XMLHttpRequest?

While I am familiar with monitoring network traffic in the browser's development tools and having XMLHttpRequests shown in the console, I am curious if there is a specific window property that showcases all network activity at once? ...

Launching a program through a web browser - a step-by-step guide

I am looking to create a specific sequence of events: A web browser opens, and a user logs in (the exact action is not crucial) The user is then redirected to a new page where another program should automatically open This process is similar to what happ ...

Getting the value of a sibling select element when a button is clicked

Trying to retrieve the selected option value on button click has become a challenge due to multiple groups of buttons and select elements. The key seems to be using siblings somehow, but the exact method remains elusive... <div class="form-group" ng-re ...