Node.js
Node.js
Example: Http.QuickGetStr method
Demonstrates theQuickGetStr method.
Chilkat Node.js Downloads
NODEJS_PRELUDE
function chilkatExample() {
var http = new chilkat.Http();
// Keep the response body if there's an error.
http.KeepResponseBody = true;
// Send the HTTP GET and return the content in a string.
var str = http.QuickGetStr("https://www.chilkatsoft.com/helloWorld.json");
if (http.LastMethodSuccess == false) {
if (http.LastStatus == 0) {
// Communications error. We did not get a response.
console.log(http.LastErrorText);
}
else {
console.log("Response status code: " + http.LastStatus);
console.log("Response body error text:");
console.log(http.LastResponseBody);
}
return;
}
console.log(str);
console.log("Success");
}
chilkatExample();