Monday, June 24, 2019

Print call stack in javascript


Print call stack on Javascript

If you want to print the javascript **call stack** you can use:

console.log(new Error().stack);

Here it is an **example**:

function firstFunction() {
function secondFunction() {
function thridFunction() {
    console.log(new Error().stack);

//=> Error
//    at thridFunction (<anonymous>:2:17)
//    at secondFunction (<anonymous>:5:5)
//    at firstFunction (<anonymous>:8:5)
//    at <anonymous>:10:1

h/t @rondale_sc

June 10, 2016

Sunday, May 19, 2019

Turning off .net core Transfer-Encoding Chuked automatic header

                var objectContent = new ObjectContent<Dictionary<string, DataTable>>(dataTablesDic, new JsonMediaTypeFormatter(), "application/json");
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(dataTablesDic);
                //setting request's content ContentLength's header was the only way I found to turn off .net core automatic Transfer-Encoding=Chunked setting, which was resulting in web api post object binding failure
                objectContent.Headers.ContentLength = Encoding.UTF8.GetByteCount(json);
                var result = httpClient.PostAsync($"http://localhost:65000/File/GetExcel?bucketDestinationPath={fileName}&S3bucketName=myBuketName", objectContent)?.Result;