Search This Blog

Tuesday, 14 May 2013

Shared javascripts-libs in flows

If you are doing a lot of validations, transformations or response-parsing you will very fast recognize that you need sometimes the same code on different routes or steps.

How about using shared javascript libaries?

Just create a javascript file with some functions like following and save it to a javascript file "sharedlib":

"sharedlib":
// sets request parameters
function setrequest(){
    request.method = 'GET';
    request.headers['Content-Type'] = 'text/html';
    request.body = "";
}

// sets the query param "fun" to given argument
function hello(message){
    request.queryParams["fun"]=message;
}


and include it in your javascript step like shown below and you are able to use this function in your normal javascript file.

"normaljsscript":
// some things you do here and then
setrequest();
hello("world");


I found no documentation about "IncludeURL" - thats a way to use it.

7 comments:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Apigee, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Apigee. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email : arun@maxmunus.com
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –http://www.maxmunus.com



    ReplyDelete

  2. This is quite educational arrange. It has famous breeding about what I rarity to vouch.
    Colossal proverb. This trumpet is a famous tone to nab to troths. Congratulations on a career well achieved.
    This arrange is synchronous s informative impolite festivity to pity. I appreciated what you ok extremely here.


    Selenium interview questions and answers
    Selenium Online training
    Selenium training in Pune
    selenium training in USA
    selenium training in chennai

    ReplyDelete
  3. Well done! Pleasant post! This truly helps me to discover the solutions for my inquiry. Trusting, that you will keep posting articles having heaps of valuable data. You're the best! 
    python training in chennai
    Python Online training in usa
    python course institute in chennai

    ReplyDelete