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

209
Views
¿Cómo obtengo datos específicos de un json data (api) usando axios en ReactJS?

Quiero obtener una imagen con texto específico en el título de la API del gráfico de Instagram. Por ejemplo, si el título de la imagen tiene la palabra "sí" en Instagram, entonces debe mostrarse en la página de inicio. El problema es que sé que no puedo escribir si promete en axios o tal vez yo No sé cómo escribir esta regla. Gracias por tu ayuda.

 import React from 'react' import '../styles/home.css' import axios from 'axios'; export default class Home extends React.Component { state = { posts: [] } componentDidMount() { axios.get(`https://graph.instagram.com/me/media?fields=id,caption,media_url,permalink,username&access_token=IGQ....`) .then(res => { const posts = res.data.data; this.setState({ posts }); }) } render() { return ( <div> { this.state.posts .map(post => <div className="banner_image"> <img className="post_img" key={post.id} src={post.media_url} alt="image"/> <div className="banner_text"> <div className="banner_content"> { this.state.posts .map(post => <h1 className="main_title" key={post.id}>{post.username}</h1> ) } {this.state.posts .map(post => <h3 className="main_caption" key={post.id}>{post.caption}</h3> ) } </div> </div> </div> ) } { this.state.posts .map(post => <img className="post_img_food" key={post.id} src={post.media_url} alt="image"/> ) } </div> ) } }

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

0

Puede probar .indexOf y hacer una declaración if que encuentre la cadena "sí" si está allí, mostrará esa imagen si no es elif o end.

 var caption = "This is some generic sentence that contains the word yes"; var substring = "yes"; console.log(caption.indexOf(substring) !== -1)

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!