is there a reason why my cloud function isnāt returning on my frontend? the server logs show the cloud function is working fine, I just canāt see it on the client
Hereās my cloud function:
Moralis.Cloud.define("userSearch", async (request) => {
const query = new Moralis.Query("User");
query.equalTo("username", request.params.search);
const results = await query.find({useMasterKey:true});
return results;
});
Hereās the front end:
class Navy extends Component {
constructor(props) {
super(props);
this.state = {
showsearch: false,
searchcontent: null
}
this.openSearch = this.openSearch.bind(this);
this.closeSearch = this.closeSearch.bind(this);
this.handleChange = this.handleChange.bind(this)
}
openSearch() {
this.setState({ showsearch: true });
}
closeSearch() {
let vm = this;
setTimeout(() => {
vm.setState({ showsearch: false });
}, 100);
}
handleChange(e) {
var value = e.target.value;
this.setState({searchcontent: value});
}
render() {
const Moralis = require('moralis')
const params = { search: this.state.searchcontent };
const results = async () => await Moralis.Cloud.run("userSearch", params);
return(
<Modal show={this.state.showsearch} onHide={this.closeSearch} size='lg' centered >
<Modal.Header >
<Modal.Title>Search</Modal.Title>
</Modal.Header>
<Modal.Body>
Search Results #: {results.length} <br/>
Result (JSON): {JSON.stringify(results)} <br/>
Result: {results}
</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={this.closeSearch}>
Close
</Button>
</Modal.Footer>
</Modal>
)}}