0

i can't get value in array IP index0, but can console.log IP. this code

const IP = []

fetch('./config.json')
  .then((response) => response.json())
  .then((json) => {
    if ( json['TEST'] === true){
      IP.push(json['IP_LOCAL'])
    } else {
      IP.push(json['IP_SERVER'])
    }
  })

console.log(IP);
// output :
// [
//   "http://192.168.1.7:8000"
// ]

console.log(IP[0]);
// output :
// undefined

can get value in array

0 Answers0