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

106
Views
How to render data from api like this

How do I render data from this api I want to render Advice from this api

    fetch("https://api.adviceslip.com/advice")
    
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can try:

import React, { useState, useEffect } from 'react';

export default function App() {
  const [advices, setAdvices] = useState([]);
  console.log(advices); // you should have the fetch data here

  async function fetchData() {
    try {
      const response = await fetch('https://api.adviceslip.com/advice');
      const data = await response.json();
      setAdvices(data.slip);
    } catch (error) {
      console.error(error);
    }
  }

  useEffect(() => {
    fetchData();
  }, []);

  return <></>;
}
about 4 years ago · Santiago Trujillo Report

0

In plain JS, see the code below or try this link

fetch("https://api.adviceslip.com/advice")
  .then(response => response.json())
  .then(data => {
    console.log('Success:', data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });
about 4 years ago · Santiago Trujillo 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!