I have a class with a constructor function and a hash function to hash certain variables. I used promises to set the variable. Here is my code:
import * as bcrypt from 'bcrypt'
import {Promise} from 'es6-promise';
const saltR: Number = 10;
export default class Hi{
    test: String;
    constructor(test: String){
        this.hash(test)
            .then((hash: String) => {
                console.log(hash)
                this.test= hash
                console.log(this.test)
            })
            .catch(err => console.error(err));
            console.log(`seller: ${this.test}`)
    }
    private hash(toBeHashed: String){
        return new Promise((resolve, reject) => {
            bcrypt.genSalt(saltR, (err, salt) => {
                if(err) reject(err);
                bcrypt.hash(toBeHashed, salt, (err, hash: String) => {
                    if(err) reject(err);
                    resolve(hash);
                });
            });
        });
    }
}
When I console.log the variable this.test after my catch() it says undefined. How can I actually set this variable and have it last?
 
    