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

77
Views
Is there a way to filter out nested null values within an api - reactjs

This is the api I'm setting it in a state after calling within componentDidMount() with axios. If you take a look at the api some profile_path of the casts are null. Was wondering how can i remove them.

Here's a codesandbox example of my code i'm calling the api in MovieDetails.jsx

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

0

You can filter them:

const mov = {"id":848278,"cast":[{"adult":false,"gender":0,"id":3148142,"known_for_department":"Acting","name":"Courtney Loggins","original_name":"Courtney Loggins","popularity":1.899,"profile_path":null,"cast_id":2,"character":"Parker Zahn","credit_id":"60e49dde07faa200774ff88a","order":0},{"adult":false,"gender":2,"id":1186714,"known_for_department":"Acting","name":"Ruben Pla","original_name":"Ruben Pla","popularity":3.134,"profile_path":"/iYdAE5VrBd2HKMy0mHcZypsuRXG.jpg","cast_id":3,"character":"Torres","credit_id":"60e49de926dac1002362250b","order":1},{"adult":false,"gender":0,"id":1875337,"known_for_department":"Acting","name":"Tarkan Dospil","original_name":"Tarkan Dospil","popularity":1.15,"profile_path":null,"cast_id":6,"character":"Valentine","credit_id":"60e49e44b76cbb00461768f0","order":2},{"adult":false,"gender":0,"id":1299438,"known_for_department":"Acting","name":"Joston Theney","original_name":"Joston Theney","popularity":0.608,"profile_path":"/btnrSBONyzu7YNerSLhr2W4f9iA.jpg","cast_id":5,"character":"Lindon","credit_id":"60e49e09258823004727e8fa","order":3},{"adult":false,"gender":0,"id":2052540,"known_for_department":"Acting","name":"Antuone Torbert","original_name":"Antuone Torbert","popularity":0.766,"profile_path":null,"cast_id":4,"character":"Blackhawk","credit_id":"60e49df76bdec300460a3fd8","order":4}],"crew":[{"adult":false,"gender":0,"id":117168,"known_for_department":"Directing","name":"Hank Braxtan","original_name":"Hank Braxtan","popularity":1.969,"profile_path":null,"credit_id":"60e49d2aa3b5e6005d8f127e","department":"Directing","job":"Director"},{"adult":false,"gender":0,"id":1346332,"known_for_department":"Writing","name":"Jeffrey Giles","original_name":"Jeffrey Giles","popularity":1.313,"profile_path":null,"credit_id":"6123c736c439c00046280d4e","department":"Writing","job":"Writer"},{"adult":false,"gender":0,"id":2223180,"known_for_department":"Writing","name":"Jacoby Bancroft","original_name":"Jacoby Bancroft","popularity":0.608,"profile_path":null,"credit_id":"6123c723bbcae0002ba28ec9","department":"Writing","job":"Writer"}]}
const result = {...mov}
const temp = result.cast.filter(d => d.profile_path !== null)
result.cast = temp
console.log(result)

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!