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

227
Views
How to get specific Data from API with Axios and React

enter image description here

I want to get a Post with specific Text in caption from Instagram graph API.For example if caption from image has "yes" word in Instagram then must show in homepage

import React,{useState} from 'react'
import axios from 'axios';
import ReactDOM from "react-dom";

export default class Deneme extends React.Component {
    constructor(props) {
      super(props);

      this.state = {
        loading: true,
        data: []
      };
    }

    getData() {
        const PostsURL = "https://graph.instagram.com/me/media?fields=id,caption,media_url,permalink,username&access_token=IG....";
        axios.get(PostsURL).then((res) => {
          const data = res.data.data;
          console.log(data)

          this.setState({
            data: data.filter(data => ['yes'].includes(data.caption)),
            loading: false,
          });
        });
      }

    async componentDidMount() {
      this.getData();
    }

    render() {
        if (this.state.loading) {
          return <div className='loadingDiv'>Calling the API, one moment please!</div>;
        }
      
        const filterData = this.state.data.filter(d =>
          ['yes'].includes(d.caption)
        )
      
        return (
          <div className="container">
              {filterData.map((d) => (
                <div className="playerDiv" key={d.id}>
                  {d.username} -  {d.caption}
                </div>
              ))}
          </div>
        );
      }
  }

about 4 years ago · Juan Pablo Isaza
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!