Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

314
Visualizações
SyntaxError: identifier starts immediately after numeric literal ts(1351)

The problem is in the title. Context: I have an API that I access with Fetch.

fetch(apiUrl)
    .then( (data) => {
        if(data.ok){
            return data.json()
        }
        throw new Error('Response not ok.'); 
    })
    .then( player => generateHtml(player))
    .catch( error => console.error('Error:', error))

But I want to display the content of the API in the HTML file. I solved it like this.

const generateHtml = (data) => {
    console.log(data)
    const html = `
        <h2 class="" >${data.profiles.028304b866cc47d18c08e902edfcb4c6.data.display_name}</h2>
        <div class="name">${data.profiles.028304b866cc47d18c08e902edfcb4c6.cute_name}</div>
        <div class="armor">${data.profiles.028304b866cc47d18c08e902edfcb4c6.items.armor_set}</div>
        <div>Rarity: ${data.profiles.028304b866cc47d18c08e902edfcb4c6.items.armor_set_rarity}</div>
    `
    const playerprofilebox = document.querySelector('#object')
    playerprofilebox.innerHTML = html

But as you can see, the element after profiles starts with a number but I can't remove the number because then the API would no longer access the correct data. Any suggestions?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Because it starts with a number, you need to access it with bracket notation:

var obj = {
    '0123abc': 10,
    '4567def': 20
};
console.log(obj['0123abc']); // 10
console.log(obj.0123abc); //SyntaxError
``
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda