Horje
async await react stackoverflow Code Example
async await react stackoverflow
constructor() {
    // ...
    this.state = { returnData: null }
}
async componentDidMount() {
   const returnData = await this.Post(...); // Using await to get the result of async func
   this.setState({ returnData });
}

async Post(body) {
  try{
    const options = {
      method: 'POST',
      uri: 'XXXXXXXXXXXXXXXXXXXX',
      body: body
    }
    return rp(options); // define await then return is unnecessary 
  }catch(e){console.warn(e)}
}

render() {
     const { returnData } = this.state;
    // ... Do the rest

}




Javascript

Related
js mysql date format and dmy format Code Example js mysql date format and dmy format Code Example
Node.js process.argv Code Example Node.js process.argv Code Example
carbon to moment js conversion Code Example carbon to moment js conversion Code Example
formula regex para validar cpf e cnpj no google forms Code Example formula regex para validar cpf e cnpj no google forms Code Example
angular input date pattern validation Code Example angular input date pattern validation Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9