When a new item is added to the JSON file, it does not appear on the browser page

Initially, I included 3 elements on the page and they displayed correctly. However, when I added a few more elements, they did not show up on the browser page without any errors.

import Image from "next/image"
import getUnits from "../libs/getUnits"

export default async function UnitsPage() {
  const units = await getUnits()
  return (
    <div className="main-container">
        <h1 className="text-5xl font-bold">Units</h1>
        
        {units.map(unit => {            
            return (
                <>                                              
                    <div key={unit.id} className="parent">
                        <div className="word-container">
                            <h2 className="word">                                                             
                                {unit.name}
                            </h2>
                        </div>
                        <div className="image-container">
                            <Image
                            src={unit.logo_way}
                            width={50}
                            height={50}
                            className="logo-inside-container"
                            /> 
                        </div>
                        <div className="logo-container">
                            <Image
                            src={unit.img_way}
                            height={200}
                            width={400}                                                  
                            />
                        </div>                                
                    </div>                  
                </>   
            )
            })
        }       
    </div>
  )
}

This code represents my main page content⬆️

{
    "items": [
        {
            "id": 1,
            "name": "Africa Korps",
            "logo_way": "/images/afr_logo.png",
            "img_way": "/images/africakorps.jpg"
        },
    
        {
            "id": 2,
            "name": "Wermacht",
            "logo_way": "/images/wer_logo.png",
            "img_way": "/images/wermacht.jpg"
        },
    
        {
            "id": 3,
            "name": "British Army",
            "logo_way": "/images/brit_logo.png",
            "img_way": "/images/british army.jpg"
        }     

        
    ]
}

The above JSON structure is used for data⬆️

If I try to add a fourth element to the JSON file, it does not display on the page and I am unsure of the reason why. 🤔

Answer №1

Ha ha, I finally cracked the code! By utilizing a local server with the JSON Server framework, all it took was tweaking the browser cache settings in developer mode to get everything up and running smoothly.

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

Slide the next section over the current section using full-page JavaScript

I'm currently developing a website utilizing the FullPage.JS script found at this link . My goal is to have the next section slide over the previous one, similar to what is demonstrated in this example. I've attempted setting the position to fix ...

ASPX responses can trigger bugs in Internet Explorer when attempting to write JSON

I'm having an issue with my ASPX page that is supposed to output JSON data. It's working perfectly fine in Firefox and Chrome, but when I try to run it in IE 8, I get an error saying "The XML page cannot be displayed" instead of loading the JSON ...

Change the border color of a form field in a material design if the user interacts with the

Is there a way to change the border color of a material form field in Angular when it is touched, focused, or active? I attempted to modify the color by overriding material css-class and also tried creating my own css class, but neither method had any ef ...

Expand the dimensions of the shinydashboard dashboard page

Currently, I am using shinydashboard and have formatted my ui code in the following way: ui = dashboardPage(skin="black", dashboardHeader(disable = T), dashboardSidebar(width=300), dashboardBody() ...

Utilizing Liferay 6.0.6's JSON API to Enhance JavaScript Functionality

I am seeking a way to access data from the Liferay portal using its JSON API through JavaScript client by making AJAX calls. After some research, I was able to find the address for the API : http://127.0.0.1:8080/tunnel-web/secure/json There is also a S ...

Implementing a hamburger menu and social media sharing buttons on websites

Currently working on my personal website and delving into the world of Web Development, I have some inquiries for seasoned developers. My first query revolves around incorporating a hamburger menu onto my site for easy navigation to other pages. After att ...

Ways to display the chosen selection post-selection of the option

My form has a table structure in HTML as shown below: <tr> <td>Quotation Category<span class="required" style="color: red">*</td> <td> <div class="form-group col-md- ...

Create a footer with a centered column orientation

I am currently working on creating a footer with four columns, one of which will display an image while the others will contain useful hyperlinks. This is what I have accomplished so far: http://jsfiddle.net/Lqh5a/ HTML <div id="wrapper"> <div ...

Display calendar with grid layout - stack tasks/notes vertically aligned at the bottom of each grid cell

Currently, I am working on incorporating a calendar feature. To display the calendar's day cells, I have utilized a grid layout. My goal is to showcase different types of tasks or notes as strips within specific grid cells. These task strips should al ...

Creating four divs in CSS/HTML where each div occupies one-quarter of the space while having borders that overlap by one pixel

Take a look at how my test page is currently set up: I want the table (created using divs, not tables) to have 4 columns that are equally spaced with borders of 1 white pixel overlapping each other horizontally. This means there should be exactly 1 white ...

Data in the form of JSON gathered from a snowflake

I am currently utilizing Snowflake for my work. These are the statements I am executing: create table test( src varchar ); insert into test values ('{"value": {"evaluation_forms": [ {"evaluations": ...

Is there a way to prevent img:hover from impacting CSS styles for screens that are 800px or wider?

After implementing the image hover in the media query for screens below 600px, I noticed that it is now affecting all screen sizes. I attempted to use display: none to halt this behavior, but unfortunately, it did not work as intended. Any helpful sugges ...

When adjusting styles using Chrome DevTools with Webpack HMR, the page layout can become distorted

Encountering a peculiar issue: Currently utilizing Webpack in conjunction with Vue-CLI and HMR. On attempting to modify styles via DevTools in the browser, the page itself undergoes unexpected changes - some styles are removed (screenshots provided below) ...

Transform PHP multidimensional array into desired JSON structure

Can someone help me restructure a multidimensional array? I'm not very experienced with arrays and could use some assistance. Here is the current array I have: $jsonArray = Array ( [0] => Array ( [category] => Array ( ...

Loop through a section of parsed JSON data in Terraform in order to generate a Map

I am working on iterating over a block that is extracted from a JSON file to create a customizable Map block. The keys and values in the JSON files can vary between different files. The extraction process is carried out using a jsondecode() function. Her ...

The card-img-overlay in Bootstrap 5 seamlessly integrates into the following div container

Currently, I am in the process of creating a painting website layout for my CS50 homepage. However, there seems to be an issue with the background-color: rgba(0,0,0,0.7); not aligning correctly with the images within the card-group. <div class="car ...

Link to toggle a CSS spoiler button

Currently, I have Ajax set up to replace the main div with a link. In addition, there's a spoiler-type navigation that allows you to hide or show the menu. I have my links inserted in this structure and am trying to figure out how to make it so that c ...

Can you leverage the class declaration from a previous style in CSS when creating a new definition?

I have exhaustively searched for the solution without success, which is leading me to believe that it may not be achievable. With my limited understanding of CSS principles, I am inclined to think that this task could pose a challenge. However, before expl ...

Using HTML and CSS to evenly align text in individual sections

Is it possible to recreate the exact look and feel of a justified page from a book or article online using HTML/CSS? This would include replicating the text justification with precise line breaks and setting the outer wrapper width to match the min/max-wid ...

Implementing event handling with .On() in Jquery following .Off()

I need assistance with my responsive navigation bar. I am having trouble with the jQuery code to disable hover events if the width is less than or equal to 768px and enable it for desktop screens. $(window).on('load resize', function (e) { v ...