i want to know the total number of request to a api using javascript

Can i know the number of requests to a api manually without quota?

0 13 179
13 REPLIES 13

Not recommended, Only JS can't do it. You need to involve some storage (KVM) and handle too many corner cases so its better to use quota which is precompiled and will be much faster than your JS code.

I will use kvm but i am looking for a simple counter..I will add 10 as a value in kvm..

If you want to just try them use JS policy with KVM.

Can you elaborate on your use case, please?

I want a counter where i will count the number of requests to the backend using kvm..

No, you can't track the request count without a Quota. Use the quota policy.

For what reason would you NOT use the quota policy?

Please guide me to generate a javascript for the same.Can we do it using the timestamp variables?

Please guide me to generate a javascript for the same.

No.

Can we do it using the timestamp variables?

No.

You're ignoring my answer, and you're not answering my question. "Why would you NOT want to use the quota policy?"

If i want to test using javascript policy

Sometimes status are only required .I dont want to stop flow using quota or spike arrest?

Can anybody help?

There is a simple configuration on almost all polices, continueOnError mark it true to execute the flow further, continueOnError="true" will be your need. Just ensure this is not recommended as you are not using these policies for their respective purpose then.

Sometimes spike arrest or quota policy may not be enough..Then we can use javascript policy...Can anybody guide me for the same using flow variables may be..

as all flow variables can be retrived on the js policy using context.getVariable() function. try this with continueOnError="true", you will get all values in the js code.