How to pass array from php to js?

There is an array:
$this->dates[]=date("Y-m-d", strtotime('monday this week')); 
 $this->dates[]=date("Y-m-d", strtotime('tuesday this week')); 
 $this->dates[]=date("Y-m-d", strtotime('wednesday this week')); 
 $this->dates[]=date("Y-m-d", strtotime('thursday this week')); 
 $this->dates[]=date("Y-m-d", strtotime('friday this week')); 
 $this->dates[]=date("Y-m-d", strtotime('saturday this week'));

Give in laravel return response()->json(['dates'=>$this->dates]); on the client:
export default {
data(){
 return {
 dates: []
}
},
 mounted() {
 let self = this;
axios
.post('http://localhost:8000/foodmenulist')
 .then(response => (this.dates.push(response['dates'])),

)
 .catch(function (error) {
console.log ("error".data);
self.$router.push('/');

});
 },

But receive nothing.
April 7th 20 at 15:43
2 answers
April 7th 20 at 15:45
Solution
response['data']['dates']
April 7th 20 at 15:47
axios
.post('http://localhost:8000/foodmenulist')
 .then(r => this.dates = r.data.dates)
dates:Array[0] - Myrtice82 commented on April 7th 20 at 15:50
@osbaldo30, ?? - garfield.Koss commented on April 7th 20 at 15:53
@Ignacio_Hait in the Vue extension in chrome so appears dates - Myrtice82 commented on April 7th 20 at 15:56
in network response
"dates":["2020-02-17","2020-02-18","2020-02-19","2020-02-20","2020-02-21","2020-02-22","2020-02-23"]
vue can such an array be read? - Myrtice82 commented on April 7th 20 at 15:59
@osbaldo30is not an array. Is a stub of some json'and. Or you are not all revealed? - garfield.Koss commented on April 7th 20 at 16:02
{"dates":["2020-02-17","2020-02-18","2020-02-19","2020-02-20","2020-02-21","2020-02-22","2020-02-23"]} - Myrtice82 commented on April 7th 20 at 16:05
@osbaldo30, empty array then take nowhere. Where did you get that it is empty? - garfield.Koss commented on April 7th 20 at 16:08
Oh, inattention laravel on the server machine all data packs in poetomu contact response['data']['dates'] - Myrtice82 commented on April 7th 20 at 16:11
laravel all the machine packs in data

@osbaldo30, are you sure? It makes axios. - garfield.Koss commented on April 7th 20 at 16:14
@Ignacio_Ha,No, I didn't.I thought larabel.Thanks for the info! - Myrtice82 commented on April 7th 20 at 16:17

Find more questions by tags AJAXJavaScript