Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
How do i get specific data from a json data (api) using axios in ReactJS

I want to get a Image with spesific Text in caption from Instagram graph api.For example if caption from image has "yes" word in Instagram then must show in homepage.The problem is i know i cant write if promises in axios or maybe i dont know how to write this rule.thank you for your help.

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 Respuestas
Responde la pregunta

0

You could try .indexOf and make a if statement that finds the string "yes" if its there it will display that picture if not elif or 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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda