Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between response.statusCode and response.status

Tags:

javascript

I was writing a function that shows dialogwindow on the button click:here the piece of code related to status and statusCode.

     if(response.status>300){
                  jQuery("#myModal").modal("show");
                }else{
    vm.someFunction();
                }


  // when I run the code above I got result working, however when I wrote //the following:



  if(response.statusCode>300){
                   jQuery("#myModal").modal("show");
                }else{
    vm.someFunction();
                }

// it does not work although my statusCode was 500;

So, my question is: what is the difference between status and statusCode and when I should use some of them.?

like image 361
Dr. Abbos Avatar asked Oct 30 '25 15:10

Dr. Abbos


1 Answers

Client-side (in the browser), and using XMLHttpRequest or fetch, the correct property to use is called response.status

Server-side, in Node.js, using http.ClientRequest (when dealing with the response of an HTTP request that you made using Node.js), the correct property to use is called response.statusCode

Also server-side, in Node.js, using http.ServerResponse (to set a status code for a particular response), the correct property to use is also called response.statusCode

like image 139
robertklep Avatar answered Nov 02 '25 05:11

robertklep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!