1
I am creating a system, and within the main codes I have large arrays of objects that store information about products and information in which I use within the functions for certain system operations.
However, storing the product information on the main code page is bothering me a lot and I would like to know if there is any way to import these object arrays from one page to another without compromising the functionalities of the functions they use as a parameter some product information.
Code example:
const produtos = [
{nome: "notebook", custo: 1.500},
{nome: "cama", custo: 2000},
{nome: "ventilador", custo: 200}
]
function getNames(){
produtos.map((produto) => {
return produto.nome
})
}
In this example, I would like to put the object array on another page, to make an import without compromising the function getNames()
. Would that be possible?
Maybe load from a JSON file using Xios?
– epx
and how I would do that?
– Ghostzeiro
you are only using vanilla javascript (html javascript)?
– greguintow
I am using JS NODE and React JS
– Ghostzeiro