getStaticProps will not return any data

I'm experiencing an issue with my getStaticProps where only one of the two db queries is returning correct data while the other returns null. What could be causing this problem?

const Dash = (props) => {

const config = props.config;

useEffect(() => {
  console.log("config", props.config) /* returns null*/
}, []);

return(/*...*/)
}

export const getStaticProps = async (ctx) => {
  const dbConnection: mysql.Connection = await mysql.createConnection({
    host: process.env.DB_HOST,
    database: process.env.DB_DATABASE,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    socketPath: process.env.DB_SOCKET
})

  const newsRes = dbConnection.query(`SELECT * FROM ucp_news`)
  const configRes = dbConnection.query(`SELECT * FROM ucp_config`)

  const responses = await Promise.all([newsRes, configRes])

  console.log(responses[1][0][0]) /* returns config value correctly */

  dbConnection.destroy()
  return {
    props: {
      news: responses[0][0], /* returns correct value */
      config: responses[1][0][0]  /* returns null instead of config value */
    }
  }

}

export default Dash;

Answer №1

Within my application, I have been utilizing a configuration parameter called "prop" passed from _app which has been overriding the value of the prop passed from getStaticProps.

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

JQuery loader & amazing animations

I have implemented the wow.js plugin along with a jQuery preload tutorial from here. Although the preloader works fine, I am facing an issue where the animation by wow.js starts before all the elements on the page are preloaded. I am looking to modify my ...

Can Autocomplete in Angular4+ support multiple selection options?

I am trying to implement a multi-selection feature on filtered items using an autocomplete function. I found inspiration from this tutorial and attempted the following code: The component : <form class="example-form"> <mat-form-field class=" ...

Disabling the submit button after submitting the form results in the page failing to load

I am encountering an issue with my HTML form that submits to another page via POST. After the form validates, I attempt to disable or hide the submit button to prevent double submission and inform the user that the next page may take some time to load. He ...

Attempting to deploy my node.js application on Heroku resulted in an error message saying that the web process failed to bind to $PORT within 60 seconds of launch, causing the process to exit with status

I recently encountered an issue while attempting to deploy my node.js app on Heroku. The error message stated that the Web process failed to bind to $PORT within 60 seconds of launch, and the Process exited with status 137. I'm unsure of how to resolv ...

Creating a lively JQ plot and saving it within an HTML file from a .aspx page using C# .net

I am currently in the process of developing a web-based application using Bootstrap. My goal is to save a .aspx page as an HTML file within my application. Upon writing the code: using System; using System.Collections.Generic; using System.Linq; using S ...

Having trouble initializing an array of objects to store data in MongoDB using AngularJS

I am facing an issue while trying to save dynamically created HTML in MongoDB using Mongoose from AngularJS. The problem lies in creating the required object that matches the Mongoose schema I have defined. model code var SegmentSchema = new Schema({ n ...

Tips for retrieving the parameter value from a Javascript regular expression

let statement = "var text = "{templateUrl: 'conversations/conversations.tpl.html',"; let outcome = statement.match(/templateUrl:(\s*['"]\S*['"])/g); The intended result should be 'conversations/conversations.tpl.html&apo ...

Adding custom styles to an unidentified child element in React using Material-UI

When the function below is executed in a loop, I need to include styles for the icon which will be passed as an argument to the function. The icon element will be an unspecified React Material-UI Icon component. const renderStyledCard = (lightMode, headi ...

Ensuring the authenticity of dynamic forms

jQuery(document).ready(function(){ $("#submitButton").click(function () { if ( $("#formToSubmit").validationEngine('validate') == true) { $("#formToSubmit").submit(); } }); Utilizing the Validation Engine plugin for jQuery to valida ...

The proper technique for invoking a class method within a callback [prototype]

I am currently working with prototype 1.7 and developing a class that is designed to take a list of divs and create a tab interface. var customTabs = Class.create({ initialize: function(container, options) { this.options = Object.extend({ ...

I am unable to fire a simple jQuery event when pressing a key until the next key is pressed

I am currently working on a project for a friend, where I have implemented a hidden text field. When the user starts typing in this field, the text is displayed in a div element to create an effect of typing directly onto the screen instead of an input fie ...

The disappearance of the checkbox is not occurring when the text three is moved before the input tag

When I move text three before the input tag, the checkbox does not disappear when clicked for the third time. However, if I keep text three after the input tag, it works fine. Do you have any suggestions on how to fix this issue? I have included my code be ...

What is the best way to showcase a value in JavaScript using CSS styling?

I'm looking to customize the background, font style, and outline for both open and closed elements in the code snippet below: a.innerHTML = "We are Open now now."; a.innerHTML = "We are Closed, arm."; Additionally, I want to appl ...

Exploring the process of acquiring a button using refs in external JavaScript

Having encountered a situation where I have two different javascript files, I came across an issue. The first file contains a finish button that was initialized by using refs. Now, I need to access this button in the second file using refs. The code snipp ...

Connect user input to a predefined value within an object

I am currently working on developing a timesheet application that allows users to input the number of hours they work daily. The user data is stored in an object, and I aim to display each user's hours (duration) in an input field within a table. An i ...

Getting PHP Post data into a jQuery ajax request can be achieved by using the `$_POST

I'm struggling to figure out how to pass the blog title into the data field of my ajax call. I've been searching for beginner tutorials on SQL, PHP, and AJAX, but haven't found anything that clarifies this issue. If anyone knows of any usefu ...

Waiting for POST request to be executed once data is inserted

This was a new experience for me; I took a break from working on the project for a while, and suddenly all POST routes stopped functioning. However, the GET routes were still working perfectly fine. After extensive debugging, I discovered that removing the ...

Creating a sidebar with child elements in Vitepress: A beginner's guide

I'm having trouble displaying my folder tree in the sidebar. When I click on a parent element like Group, the children elements are not showing up as expected. One strange thing is that the Group elements do not have the CSS property cursor: pointer ...

Quicker method for displaying an element in an array than utilizing a for loop

Having an array as shown below: var arra= new String [50,50]; // New entries are added to the array and for each row added, count is increased by 1. The columns go up till incount which is always less than 50. for(i=0;i<=count;i++) { for(j=0;j<in ...

Setting up 'ngProgress' as a loader in my project using the 'ngbp boilerplate' is straightforward and easily customizable

Currently, I am utilizing the 'ngbp' angular boilerplate from GitHub to develop my project. My goal is to implement ngProgress for displaying a loader when navigating between sections. I have successfully installed ngProgress via bower and ensur ...