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

248
Views
How can I get specific data from html in React Native?
  const fetchData = async () =>  {

  fetch('https://*******/*****search-value={value}')
  .then(response => response.text())
  .then(data => {
      console.log(data);
  })
  .catch(err => console.error(err));
  }

I succesfully got the data from the api (it returns full html), and I got this response:

<div class="col-md-12">
    <p class="text-info strong">
     Succes.
    </p>
    <table class="table">
        <tr>
            <td width="40%">Number:</td>
            <td>900000000053901</td>
        </tr>
        <tr>
            <td>ID</td>
            <td></td>
        </tr>
        <tr>
            <td>Name:</td>
            <td>Grafit</td>
        </tr>
        <tr>
            <td>Spiece:</td>
            <td>kutya</td>
        </tr>
        <tr>
            <td>Type:</td>
            <td>Border collie</td>
        </tr>
        <tr>
            <td>Gender:</td>
            <td>hím</td>
        </tr>
        <tr>
            <td>Last modified:</td>
            <td></td>
        </tr>
        <tr>
            <td>Dangerous:</td>
            <td>
                                Nem
                            </td>
        </tr>
        <tr>
            <td>Last vaccine:</td>
            <td>Intervet Nobivac DHPPi+RL, 2018.02.17</td>
        </tr>
        <tr>
            <td>isDead:</td>
            <td>
                                Nem
                            </td>
        </tr>

    </table>

Now I want to see the data from class="text-info strong" if Succes or not. If Succes I want to read the html table () and parse it to a json.

{ Number: 900000000053901, ID:"", Name:"Grafit", ... }

How can I achieve this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could do it with something like this:

function tableToJson(table) {
    const data = [];
    for (let i = 1; i < table.rows.length; i++) {
        const tableRow = table.rows[i];
        const rowData = {};
        rowData[tableRow.cells[0].textContent] =
            tableRow.cells[1].textContent.replace(/\n\ +/gm, '');
        data.push(rowData);
    }
    return data;
}

const dataHTML = document.createElement('div');
dataHTML.innerHTML = data;
const isSuccess =
    dataHTML.querySelector('.text-info.strong').textContent === 'success';
if(!isSuccess) return false;
const table = dataHTML.getElementsByTagName('table')[0];
return tableToJson(table);
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!