In Ionic application, we are integrating AWS-Amplify and we can able to insert and fetch the data. But while implementing subscription we are getting compiler error says
Property 'subscribe' does not exist on type 'Promise | Observable'. Property 'subscribe' does not exist on type 'Promise'.
In Subscription.ts
export const onCreateEmployee = `subscription OnCreateEmployee(
$employee_id: Int
$employee_name: String
) {
onCreateEmployee(
employee_id: $employee_id
employee_name: $employee_name
) {
employee_id
employee_name
}
}
In Main.ts
const subscription = API.graphql(
graphqlOperation(onCreateEmployee)
).subscribe((eventData) => { console.log(eventData)
});
In main.ts, it shows the error like cannot subscribe ..... (see the above error).
Can anybody know how to resolve this?
Thanks