How to pass JSON object to provisioning script

How are you passing this data to your provisioning script? Via an extension script? Via the arguments option when executing a provision script via a preset?

FWIW, I pass data from my provision script by doing let config = ext('cpe-config', 'resetPppoe', JSON.stringify(params));

config is the output from the ext script, and is a json object.

Here is the part of my ext script that makes the call to our subscriber management system and returns the data to the provisioning script. Notice the line towards the bottom that parses the incoming data from a string into a JSON object and then returns that data via the callback.

let request = http.get(options, function (response) {
    if (response.statusCode === 404) {
        return callback(null, null);
    }

    if (response.statusCode >= 400) {
        return callback(new Error("Unexpected error resetting PPPoE credentials. Response Code: " + response.statusCode + '. Status Message: ' + response.statusMessage + '. t: ' + typeof response.statusCode));
    }

    let data = "";
    response.on("data", function (d) {
        data = data + d.toString();
    });

    response.on("end", function () {
        let result = JSON.parse(data);

        console.log('Returning credentials to client', result);
        return callback(null, result);
    });
});

request.on("error", function (err) {
    console.log('args');
    console.log(arguments);
    callback(err);
});
1 Like