Hello i'm trying to set the response i'am getting from my backend to State. But i allways get this error.
TypeError: this.setState is not a function
can someone pls tell me how i can set my response to the state ?
recalcRequest(data){
let meth = data
let brandCode = meth.brandCode
let paymentAmount = this.props.location.query.anfrage.umsatz+"00"
let merchantReference = this.props.location.query.cardid
let jsonData = {
brandCode : brandCode,
paymentAmount : paymentAmount,
merchantReference:merchantReference
};
request.post({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url: 'http://localhost:8888/Backend/recalcSig.php',
body: "data=" + JSON.stringify(jsonData)
}, function(err, response, body){
if (err) throw err;
body = JSON.parse(body)
this.setState({
merchantSig: body.merchantSig,
sessionValidity: body.request.sessionValidity,
requestPaymentMethods: false,
showCardDetails:true
})
console.log('response: ', response);
})
}