Sample code for 30+ languages & platforms
Node.js

Transition from Http.PostJson2 to Http.HttpStr

Provides instructions for replacing deprecated PostJson2 method calls with HttpStr.

Chilkat Node.js Downloads

Node.js
NODEJS_PRELUDE

function chilkatExample() {

    var success = false;

    var http = new chilkat.Http();

    var url = "https://example.com/something";
    var contentType = "application/json";
    var jsonText = "{ ... }";

    //  ------------------------------------------------------------------------
    //  The PostJson2 method is deprecated:

    // responseObj: HttpResponse
    var responseObj = http.PostJson2(url,contentType,jsonText);
    if (http.LastMethodSuccess == false) {
        console.log(http.LastErrorText);
        return;
    }

    //  ...
    //  ...

    //  ------------------------------------------------------------------------
    //  Do the equivalent using HttpStr.
    //  Your application creates a new, empty HttpResponse object which is passed 
    //  in the last argument and filled upon success.

    var responseOut = new chilkat.HttpResponse();
    success = http.HttpStr("POST",url,jsonText,"utf-8",contentType,responseOut);
    if (success == false) {
        console.log(http.LastErrorText);
        return;
    }


}

chilkatExample();