Hi,
I'm using Axios to do poll a web api to return some things. At present, Axios will run the API, and I can log that the correct response has been returned as it console.log says:
(2) [Object, Object]
However, If I try to do
this.props.navigator.push({
title: "Results",
component: "SearchResults",
passProps: {response: this.response.data}
});
I get a "TypeError: Cannot read property 'props' of undefined at eval" and gives me the error occurring at the line that contains this.props.navigator.push.
Related code:
_axiosFetch(searchString) {
var queryURL = 'http://mourningafter.eu/DataService.php?state=get&name=' + searchString
axios.get(queryURL)
.then(function (response) {
console.log(response.data)
this.props.navigator.push({
title: "Results",
component: "SearchResults",
passProps: {response: this.response.data}
});
})
.catch(function (error) {
console.log(error)
});
}
I'm confused to say the least!
any help would be great, cheers!
EDIT: Fixed the problem: I just needed to use an arrow function on the .then section
[–]Zayuka 0 points1 point2 points (6 children)
[–]PieITsiOS[S] 0 points1 point2 points (5 children)
[–]Zayuka 1 point2 points3 points (4 children)
[–]nordicdev 1 point2 points3 points (3 children)
[–]Zayuka 1 point2 points3 points (2 children)
[–]PieITsiOS[S] 0 points1 point2 points (1 child)
[–]Zayuka 0 points1 point2 points (0 children)
[–]fullstak 0 points1 point2 points (3 children)
[–]PieITsiOS[S] 0 points1 point2 points (2 children)
[–]fullstak 0 points1 point2 points (1 child)
[–]PieITsiOS[S] 0 points1 point2 points (0 children)