Visualizer Documented Script Stopped Working

This script in your documentation has recently broken - cannot seem to find why

https://www.postman.com/postman/workspace/postman-team-collections/request/3407886-0cd8c17f-45bc-48b0-9be0-cd7d7704425d?ctx=documentation

Hey @robsherali :wave:

Welcome to the Postman Community! :postman:

It seems fine for me, after I forked the Collection into my Workspace:

Could you expand more of what’s broken? Are you seeing an error message?

Thanks for the rapid response! When I inspect the Vizualiser its giving me a “Uncaught Ref Error $ not defined” - strange as this was working a couple days back and nothings been changed?

<script>
$(function() {
    pm.getData((err, data) => {
        $("#json").val(JSON.stringify(data.json));
        json2table("#html");
    });
});

What request are you running this against?

Can you provide an example response?

[
    {
        "Code": "A",
        "Description": "Afghan",
        "LookupName": "nationality"
    },
    {
        "Code": "B",
        "Description": "Albanian",
        "LookupName": "nationality"
    },
    {
        "Code": "C",
        "Description": "Algerian",
        "LookupName": "nationality"
    }
]

That appears to be working fine.

The example request is using Postman Echo, so duplicate the “Visualise and JSON data” request and then copy and paste your example response into the request body.

You need to make one change to the code in the tests tab, and that is to parse to the data element in the echoed response. This should then mimic your response.

let tableProps = {
    json: pm.response.json().data
};

This appears to visualise fine.

image

So appreciating this thanks - however did what you suggested and still getting the same empty result. I cannot seem to upload images however not sure if this additional error info helps - given you are saying it is working maybe its something to do with a work network issue in js?:

Failed to load resource: net::ERR_CONNECTION_CLOSED in jquery.min.js:1
Uncaught ReferenceError: $ is not defined

Oh my - SOLVED! Just had to change the js call away from https to http:

FAILING

WORKING

Many thanks all for your help

1 Like

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