Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

318
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!