I want to get the customers last name but i get the following error any idea how to fix that ?
And is there a way to modify my current get function so that it returns the first name and last name at once ?
Unhandled Rejection (TypeError): _this.contarct.getLastName(...).call is not a function
React:
changeLastName(e){
e.preventDefault();
let id = e.target.dataset.somefield;
this.contarct.getLastName(id).call().then((lastName)=>{
this.setState({lastName:lastName});
}
);
}
<form data-somefield={this.id} onSubmit={this.changeLastName}>
<input type="text" name="id"/>
<input type="text"/>
</form>
<p>{this.state.lastName}</p>
solidity:
struct {
string lastName;
}
getLastName(unit256 _id)public view returns (string){
unit256 id = customersIndex[_id];
return customers[id].lastName;
}