{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • General /
avatar image
1
Question by vinod kumar reddy y · Mar 26, 2019 at 05:38 AM · 574 Views javascriptjavascript policy

JavaScript callback support in httpClient is not working

Hi,

I'm trying httpClient in JavaScript policy to make mock target call with below snippet

function onComplete(response, error) {
  print("inside onComplete",response);
  print("error",error);
  if (response) {
    context.setVariable('example.status', response.status);
  } else {
    context.setVariable('example.error', 'Woops: ' + error);
  }
}

print("before hitting mock server");

// Function callback allowed as an argument. 
httpClient.get("http://mocktarget.apigee.net/json",onComplete);

Callback is not happening with above snippet, Can you please help on this?

If i make a call using waitForComplete() then i was able to see the response. The snippet used in this case is below

var ex1 = httpClient.get("http://mocktarget.apigee.net/json");
ex1.waitForComplete();
if (ex1.isSuccess()) {
  response1 = ex1.getResponse();
  print("response after waitForComplete",response1.content);
  context.setVariable('example.status',response1.status);
} else {
  error = ex1.getError();
  context.setVariable('example.error','Woops: ' + error);
}
Comment
Add comment Show 2
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Dino-at-Google ♦♦   · Mar 26, 2019 at 02:42 PM 0
Link

Managing your own Edge instance? Or using SaaS?

avatar image vinod kumar reddy y Dino-at-Google ♦♦ · Mar 27, 2019 at 04:45 AM 0
Link

Hi Dino,

its a SaaS version.

Close

1 Answer

  • Sort: 
avatar image
1

Answer by Kuldeep Bhati   · Mar 26, 2019 at 11:37 AM

Hi @vinod kumar reddy y,

I experienced the same behavior when I tried this code on my org, however when I tried on other newly created evaluation org, it works! It seems the update - https://docs.apigee.com/release/notes/180608-apigee-edge-public-cloud-release-notes has not been pushed to your org as well as mine, I suggest you to get in touch with Apigee Support to fix this.

Comment
Add comment Show 1 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image vinod kumar reddy y · Mar 27, 2019 at 04:47 AM 0
Link

Hi Kuldeep,

Thanks for your reply, I had a try with new one as well but not able to view callback triggered

Follow this Question

Answers Answers and Comments

62 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

JavaScript Callout Policy 2 Answers

Parse json payload and change specific values according to pattern search 1 Answer

MessageLogging Policy or new JavaScript file 3 Answers

Getting some error if my variable name contains "hiphen" in the name inside javascript. 1 Answer

Unit testing of JavaScript Policy 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges