The outcome of the Next.js query has not been explicitly provided

Currently, I am learning Next.js (TypeScript) and I have created the function getServerSideProps({query}) in detail/[slug].tsx. However, the query does not provide the expected result in the URL.

For example, when the URL is localhost:3000/detail/samsung-s23?variant=black, the value of query in the getServerSideProps() function is:

query:{
  slug:'wow',
}

Even when I tried hardcoding the slug as 'samsung-23', it was still being replaced by 'wow'. This issue persists even with dummy data.

Below is a snippet of my code:

export async function getServerSideProps({ query }) {
  console.log('request', query)
  
  return {
    props: {
      slug: 'Samsung-s23-ram-8',
    },
  }
}

const Detail = ({ slug }) => {
  console.log(slug)
  const id = 'asddwases126'

  return (
    <PDPFullLayouts>
      <ProductDetails
        productId={id}
        detailProduct={dataDetail.detailProducts}
      />
      <PopularProducts />
    </PDPFullLayouts>
  )
}

I'm facing an issue where the slug from the request is always returned as wow. How can I update the slug to reflect the correct value?

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

The value of Vue.js props appears as undefined

It appears that I may be misunderstanding how props work, as I am encountering difficulty passing a prop to a component and retrieving its value, since it always shows up as undefined. Route: { path: '/account/:username', name: 'accco ...

What is the most effective method for informing the browser about changes in the database?

I've been working with django for about 6 months now and it has been effective for the websites I create. However, I recently encountered an issue while developing a website where users receive notifications whenever another user updates a blog post. ...

What is the best way to obtain a list of all the modules that are currently accessible in AngularJS

When declaring an Angular module, I specify its dependencies as follows: const myModule = angular.module("MyModuleName", ["Dep1", "Dep2", "Dep3"]); Each dependency comes with its own set of dependencies, directives, controllers, etc. Is there a way to qu ...

Ensure the initial value in the dropdown menu is automatically set to the first value in VueJs

How can I set the first value of my time object as the default value for my dropdown in Vue? I want the first value to be pre-selected when a user enters the website, but currently only display the value without actually selecting it. time Object:- { &quo ...

A guide to retrieving nested values from a JSON object using JavaScript

Having trouble accessing specific values from a heavily nested JSON content returned by a URL? You're not alone! Many tutorials only cover simple nesting examples. Take a look at the code snippet I've been working on: $(document).ready(function ...

Error 19: Constraint violation - duplicate entry detected

While trying to set up my app, create a local database, and insert the very first user who has logged in locally, I encountered an error message at a specific point in the code. Here's where it happened: angular.module("greenApp") .service("d ...

Load various information retrieved from an HTTP API into a SQLite database

I am currently working on an Ionic2 project that requires users to log in before gaining access to the system. Once the login is successful, I need to post their username to another API to retrieve a list of all entries made by them. The challenge I am fac ...

undefined event typescript this reactjs

I have come across the following TypeScript-written component. The type definitions are from definitelytyped.org. I have bound the onWheel event to a function, but every time it is triggered, this becomes undefined. So, how can I access the referenced el ...

Ways to extract the coordinates for slices positioned around the circumference of a pie chart

Currently, I am working on designing a pie chart with D3 using d3.layout.pie(). The image resembles the one displayed below, but without the black dots. These dots were added manually in Photoshop to highlight an issue that I am facing. I am curious about ...

JavaScript Bridge function in WebView not invoked

I encountered a strange issue with my application, which functions as an e-reader. To invoke functions for the web view, I utilize a JavaScript class: public class MyJavaScriptInterface { Context mContext; /* Instantiate the interface ...

How to Use Framer Motion in Next.js for window.innerWidth Less Than 768

I am trying to use window.innerWidth to control the timing of an animation (Framer Motion) in my Next.js project, but I keep encountering the error message: ReferenceError: window is not defined Here's a simplified version of my ValuesSection.jsx co ...

A new sub-schema has been created in the JSON schema specifically tailored to a certain property

I needed to create a JSON schema with 3 fields: num, key1, and key2. The fields num and key1 are required, while the field key2 is only mandatory if key1 has a value of 'abc'. Below is the schema structure I came up with: schema = { type: &ap ...

Click on a custom marker on Google Maps to reveal a pop-up info window with more details

I have successfully created a personalized Google Map using Custom Markers. Now, I am looking to incorporate Info Windows for each marker. The code for the Custom Markers can be found at: https://developers.google.com/maps/documentation/javascript/custom- ...

Node.js Conditional Logic using Javascript

Can a check be implemented for the following scenario? A continuous loop of numbers, such as 1 2 3 4, is being sent to the server. However, I only want each number to be accepted once. Here is my current approach. I believe I am missing one additional c ...

How can I invoke a custom function asynchronously with JavaScript?

Incorporating a specific angular third party module into my application has posed some challenges. This module offers various call-back methods such as login success and failure, where I have embedded my custom scripts for execution. However, the current ...

AngularJS ng-repeat is not updating when the state changes

Seeking assistance with an Angular application challenge I'm facing. I have implemented a ng-repeat in my app to display the latest messages stored in an array within a controller named "comunicacion": ng-repeat in comunicacion.html <div class=" ...

Issue encountered while attempting to load external JSON file from server in AngularJS

Currently, I am attempting to load a JSON file from the server. Below is my services.js file: angular.module('starter.services', []) /** * A simple example service that returns some data. */ .factory('Friends', function($http) { ...

How should we correctly import jquery.inputmask?

Struggling to import jquery.inputmask using webpack and TypeScript? Head over to this discussion at Issue #1115 : Here's how I configured things with jqlite: To import in your app, use the following code: import InputMask from 'inputmask&apos ...

Explain the inner workings of the setTimeout() function in JavaScript

My goal is to create a line in my code by placing points according to the line equation and adding a 100 millisecond delay before each point is displayed. However, when I try to run the code, it seems to wait for some time and then displays all the points ...

When attempting to print a Rectangle on my webpage using JavaScript and taking user input, I encountered an error stating that 'str' is not defined

I'm trying to implement a feature where clicking on the "try it" button will prompt the user for the number of lines and then print that many lines in the form of a rectangle. However, when I run my code, nothing appears on the DOM and there is an err ...