Received unexpected response from parent

Hii

I am getting this error in the Iparams page, Function is giving an error when we make api call after click event catched using Jquery or dom. if we use directly it is giving correct response.

Hi @Balchand_Patidar

Can you try with the below snippet?

function verifyAccount() {
  console.log('inside verify account function');
  client.request.get('https://domain.com').then((data) => console.log(data));
}
$(document).ready(function () {
  app.initialized()
    .then(function (_client) {
      console.log('app initialized triggered')
      window.client = _client;
      client.events.on('app.activated', initButton);
      function initButton() {
        console.log('app activated triggered');
        jQuery('#submitButton').click(() => {
          console.log('clicked');
          verifyAccount();
        });
      }
    });
});

Include jQuery script in the index/template.html file

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>

Please verify if app initialised and app activated events are triggered properly. Please let me know if you face any issues.

Regards,
Mughela Chandresh

2 Likes

Hello @Balchand_Patidar , I might be wrong here, but can this have to do anything with the fact that you are getting undefined headers as I see at the top of the logs? I do not see any parameters passed at the vefirfyAccount() function that is being called after clicking the submitButton.

we have hardcoded the domain and api key, to avoid any extra error from code level

not getting any response

@Balchand_Patidar

Did you check if the app initialized, app activated and button click events are triggered properly?

1 Like

@Mughela_Chandresh
Yes, it is triggered, and when we click the button this error has occurred from freshclient.

@Balchand_Patidar
It would be helpful if you can DM me the app zip so that I can check it from my end.

@Mughela_Chandresh
please find the app zip
Api_Test.zip (3.3 KB)

I have checked the above app from my end and it seems to work fine in local testing. Does it work fine for you in your local testing?

No it is giving that requestAPI error

@Balchand_Patidar

Seems like this happens due to form submission. During submission the page reloads. This leads to context getting lost. Ideally, you should use e.preventDefault() for the form submit handler. Please refactor the app with the above changes and check if the issue is fixed.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.