Reputation: 13
i'm post data to nav and get it after post i use
.then(data => console.log(data.PathPDF))
.then(data => window.open(data.PathPDF, '_blank', 'noopener,noreferrer'));
in the first line i can get value in console but in window.open get error "Cannot read property 'PathPDF' of undefined"
Upvotes: 0
Views: 33
Reputation: 85012
.then(data => console.log(data.PathPDF))
Whatever value you return from your .then
callback becomes the value in the resulting promise. console.log
returns undefined
, and so that's the value your second .then
gets passed in.
Either change this to re-return the data
:
.then(data => {
console.log(data.PathPDF)
return data;
})
.then(data => window.open(data.PathPDF, '_blank', 'noopener,noreferrer'));
Or just have a single .then
:
.then(data => {
console.log(data.PathPDF);
return window.open(data.PathPDF, '_blank', 'noopener,noreferrer');
})
Upvotes: 2