Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IHttp won't work in the app implement IPreMessageSentModify #664

Open
lent85 opened this issue Sep 13, 2023 · 0 comments
Open

IHttp won't work in the app implement IPreMessageSentModify #664

lent85 opened this issue Sep 13, 2023 · 0 comments

Comments

@lent85
Copy link

lent85 commented Sep 13, 2023

Develop a custom app with ability to call API and custom the message base on the response. But won't able to get the IHttp work in anyway.

Sample code:

public async executePreMessageSentModify(
        message: IMessage, builder: IMessageBuilder, read: IRead, http: IHttp, persistence: IPersistence): Promise<IMessage> {
        this.checkHttp(http, "executePreMessageSentModify");
}
private async checkHttp(http: IHttp, prefix: string): Promise<void> {
        try {
            const testResponse = await http.get('https://google.com', {
                timeout: 3000, 
                strictSSL: false,
                rejectUnauthorized: false
            });

            if (testResponse && testResponse.statusCode === 200) {
                await this.getLogger().log('Precheck @ ' + prefix + ': HTTP object is okay to use');
            } else {
                await this.getLogger().log('Precheck @ ' + prefix + ': Got non-200 status code', testResponse ? testResponse.statusCode : 'No Response');
            }
        } catch (error) {
            await this.getLogger().error('Precheck @ ' + prefix + ': HTTP object is not okay to use:', error.message);
        }
    }

this code always return the No Response as testResponse is always undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant