Establishing a fresh JSON upload module

I have this JSON object stored in a file called object.json.

Every time the method getAlbum() is called during an HTTP request, the JSON object is cached because it is imported at the top of the page.

Is there a way to create a new instance of the object to clear the JSON cache each time?

Since the JSON object has many fields and deep nested structure, simply creating a new Object() won't work.

const albumReportJSON = require('./album.report.json');

const getAlbum = async(ctx) => {
  const value = albumReportJSON;
  // processing...
}

Answer №1

Utilize the json data within your function

const fetchAlbum = async(ctx) => {
  const albumDataJSON = require('./album.data.json');
  // Alternatively, you can simply use const info = require('./album.data.json');
  const info = albumDataJSON;
  /.. performing operations
}

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

When using express, the response.sendFile() function is causing an Uncaught SyntaxError with the error message: Unexpected token <

Currently, I'm utilizing react-router with browserHistory. There is a specific function in my code that is meant to send the Index.html file since the routing is handled client-side with react-router. However, there seems to be an issue where the serv ...

Obtain a specific element in Puppeteer JS by utilizing the waitForSelector function to detect when its class name changes

I am faced with a situation where I need to wait for a specific element to change its classes dynamically. The challenge arises when utilizing the waitForSelector function, as it fails to work when no new element is added to the DOM. Instead, it is the &l ...

Tips for unraveling intricate JSON data structures in Dart/Flutter

Following my server request, I received the following JSON data: [ { "id": 56012, "name": "The name", "description": "<p>description</p>\n", "regula ...

How can we stop a form from being submitted when the input field is

Similar Question: How to prevent submitting the HTML form’s input field value if it empty <?php include '../core/init.php'; if(isset($_POST['nt']) && isset($_POST['ntb'])){ mysql_query("INSERT INTO `pos ...

Is there a way to configure my datepicker so that it displays only dates that are later than a specified date

At the heart of my inquiry lies a dilemma: I have two date pickers, one for leave_start and the other for leave_end. If an individual selects "YES" for a future text_field, I aim to ensure that the date pickers only display dates after the person's an ...

Having trouble retrieving data from an array within a JSON object

I've spent countless hours searching for a solution to this issue, but no matter what I attempt, I keep running into the same error message. The dreaded error I keep encountering is: Fatal error: Cannot use object of type stdClass as array My curren ...

Issue with Vuetify carousel not resizing to fit the entire width and height

I am looking to create a carousel that spans the entire width and height of a viewport in my Vue.js 2 project using Vuetify. Below is the code I have so far: <head> <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500, ...

Difficulty encountered while AngularJS is integrating ASP.NET PartialView

I am facing an issue with processing HTML obtained from a PartialView Ajax call in AngularJS. The complication arises from the fact that some JavaScript code is updating the element.html property after the page has loaded. Unfortunately, I am unable to mod ...

Tips for transforming a recursive/nested OpenStruct object into a hash

I am trying to convert an OpenStruct object into JSON data. Here's a sample Hash (from RSPEC helper): def test_order { "id": 505311428702, "email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="04706177704463696 ...

Tips for passing a value or argument to the map function in JavaScript

Can someone guide me on how to pass a variable in the map function using JavaScript? const obj = ["Singapore", "Malaysia"] const pr = ["SG", "MY"] // need to pass value to map function render(){ obj.map((val, index) => { return html` <p ...

One specific JS file fails to load only when using Internet Explorer Browser in conjunction with the debugger

I am encountering an issue with a project that utilizes angular JavaScript controllers to populate fields. Unfortunately, a specific page, members.cshtml, is not loading properly in Internet Explorer 11, despite working perfectly on Chrome and Firefox. Af ...

What is the best way to delete a parent table row in React JS when the child "delete" button is clicked?

Struggling with hiding a table row in my React JS app upon clicking the "delete" button. The functions causing issues are: ... changeHandler: function(e) { ... }, deleteHandler: function(e) { e.currentTarget.closest("tr").style.visibility = "hidden"; } ...

Extracting data from an API response with rest Assured: A simple guide

I am new to utilizing Rest Assured for API testing. My response JSON contains nested arrays with details of spends on various merchants, and I specifically need to extract the spend value for Netflix. How can I create a condition to retrieve the absolute v ...

Error: The method onSaveExpenseData in props is not defined as a function

I am currently learning how to pass data from a child component to a parent component in React I encountered an error: TypeError: props.onSaveExpenseData is not a function I would appreciate any help as I am still in the learning phase and this error has ...

The visibility of content that flickers on the webpage should be hidden with the display: none property during loading

Currently working on a new toy website, but encountering some unexpected behavior. On the homepage HTML file, there are two separate sets of <body> tags: <body class = "intro">...</body> <body class = "home">...</body& ...

crafting connections in 3D using TypeORM (ORM)

I attempted to construct a database schema involving users, groups, documents, and permissions. Users can be part of multiple groups Groups can have multiple users Users can possess permissions for documents Groups can have permissions for documents Perm ...

Is there a way to refresh a MongoDB database automatically without relying on requests?

Is there a way to automatically refresh the MongoDB database without relying on user requests in order to ensure maintainable database requests and API calls that do not exceed any limits? My tech stack includes Node, Express, Vue, and Mongo. What concept ...

Using data binding in VueJS to construct a dynamic URL

Exploring VueJS for the first time and it's been a great experience so far. However, I'm facing a couple of challenges with data binding. The requirement is for the customer to input an image URL, and no image should be displayed until a valid ...

Move the <div></div> element to the bottom of the webpage and center it

My HTML includes a <div>...</div> section that serves as a toolbar. Is there a method to position this section at the bottom of the webpage (document, not viewport) and align it to the center? ...

Unable to Retrieve Modified Content with $().text();

In the process of developing an app, I am encountering a challenge where I need to transfer user input to another element after processing it. However, I am facing an issue with accessing the updated value of the <textarea> using .text(), as it only ...