Api ai javascript is request error

I used ionic call dialogflow .
run android device error but ionic serve not error
error say “api ai javascript is request error”

import {ApiAiClient} from “api-ai-javascript”;
platform.ready().then(() => {
const client = new ApiAiClient({accessToken: ‘aaaaaaaaaaaaaaaaaaaaa’});
client.textRequest(‘Hello!’)
.then((response) => { this.alertController(“y”,“y”) })
.catch((error) => { this.alertController(“n”,“n”) })
});

1.Please explain clearly what you want , and what you are getting
2.Please insert code in code blocks.

Thanks

I use ApiAiClient for connect dialogflow.
I run in ionic serve is response.
I build android and test app in device but it is not response.

import { Component } from ‘@angular/core’;
import { Platform ,NavController,AlertController } from ‘ionic-angular’;
import { Injectable } from ‘@angular/core’;
import {ApiAiClient} from “api-ai-javascript”;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
@Injectable()
export class HomePage {

constructor(public navCtrl: NavController,public alertCtrl: AlertController,private platform: Platform) {
platform.ready().then(() => {
const client = new ApiAiClient({accessToken: ‘aaaaaaaaaaaaaaaaaaaaaaaa’});
client.textRequest(‘Hello!’)
.then((response) => { this.alertController(“y”,“y”) })
.catch((error) => { this.alertController(“n”,“n”) })
});

}

alertController(head,text){
let alert = this.alertCtrl.create({
title: head,
subTitle: text,
buttons: [‘OK’],
enableBackdropDismiss: false // <- Here! :slight_smile:
});

alert.present();

}

}

Are you using ApiAiClient for network request?
question still unanswered what you want to achieve.
Something that I understood is

1.You want to show alert but its not working.
OR
2.You are trying network request with ApiAIClient but its not working

I select 2.You are trying network request with ApiAIClient but its not working.
ApiAIClient its not working on android device.

I run ionic serve : go to loop then.
I build and run on android device : go to loop catch and alert “Api Ai Request Error”

If its for Network request then from my experience I can suggest you to use
1.Angular Http client

OR

2.Ionic Native Http

Because these two api can best support for api/network request.

dialogflow can 't connect by Http client;
dialogflow connect api ai client only by used tokken

Then I have no info about that.

I think their docs can help you better.
But if anyways you solve it then please share so that it will helpful to others.

Thanks