React code sometimes work correct sometimes not

Hi, I wont to make an app which fetch some pics of NASA image of the day.I show the today’s pic and some (4 for example) previous.I use datepicker to choose the image of the day of date by my choice .The problem is sometimes it work fine, sometimes shows only the today’s photo, sometimes today’s plus one or two previous.Can someone explain what’s going on ?

import React, { Component } from "react";
import DateInput from "./components/DateInput.js";
import Photo from "./components/Photo.js";
import Axios from "axios";

class App extends Component {
  state = {
    date: new Date(),
    currentPhoto: "",
       .then(response => this.setState({currentPhoto:}));
   getImages = n => {
    const daysBuffer = [];
 for(let i=1; i<n; i++){      
      let today = new Date();
    const picBuffer = [];
    const datesBuffer = => this.getDate(day)); => {
       .then(response => picBuffer.push(;
    this.setState({photos: picBuffer});
  getDate = time => {
    let year = time.getFullYear();
    let month = time.getMonth();
    let day = time.getDate();
      return (
   getPhoto = a => {
    let date = this.getDate(a);
     .then(response => this.setState({currentPhoto:}))
  changeDate = date => {
  render() {
      const imageGrid = => {
               return (
                 <Photo photo = {pic} key={} />
    return (
        <h1>NASA's Astronomy Picture of the Day</h1>
                 changeDate = {this.changeDate}
                 date = {}
                 <Photo photo = {this.state.currentPhoto} />

export default App;

import React from "react";
import DatePicker from 'react-datepicker';
import "react-datepicker/dist/react-datepicker.css";

const DateInput = props => (
   Select a Date: 
    selected = {}
    onChange = {props.changeDate}

export default DateInput;

import React from 'react';

const Photo = props => (
        <img src={} alt={} />

export default Photo;

Did you make sure you did reset catch/cookies tried a diffrend browser? That’s the first thing I would do :3

Yes, rest cookies, test it with Firefox and Chromium but there is no effect.It’s interesting that in always are four objects but render method does not work properly and if I choose date from datepicker , then all other images appear.

Is there a limit on the DEMO_KEY for request?

DEMO_KEY Rate Limits

In documentation examples, the special DEMO_KEY api key is used. This API key can be used for initially exploring APIs prior to signing up, but it has much lower rate limits, so you’re encouraged to signup for your own API key if you plan to use the API (signup is quick and easy). The rate limits for the DEMO_KEY are:


I upload the code with DEMO_KEY but in my app I use my key(which received after registration). I fetch the the photos put them in the state.When I check the objects with url. , title etc. are there. After that when I have to render them something go wrong.