Skip to content

API Monitor: Using Eval to access returned JSON data #200

Closed Answered by rajnandan1
dug42 asked this question in Q&A
Discussion options

You must be logged in to vote

@dug42 The eval is validated against (200, 1000, "e30=") which translates to (200, 1000, '{}') within the function. So whatever function you write should be able to handle these values otherwise you won't be able to save the monitor.

For your use case you will have to add validations

Attempt 1 - using find()

(function (statusCode, responseTime, responseDataBase64) {
    const resp = JSON.parse(atob(responseDataBase64));
    let node_key = "Webhooks";
    let status = "DOWN";
    if(statusCode >= 200 && statusCode <= 399) {
        if (responseTime > 2000) {
            status = "DEGRADED";
        } else if(!!resp.components) {
            let webhook_component = resp.components.find(comp…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rajnandan1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
eval queries around eval
2 participants