[#260] Deprecate Synchronous request

Migrated from Redmine #260 | Author: David Saenz
Status: Resolved | Priority: Normal | Created: 2018-10-17


Hi
When I try to do this:

let loginClient = new JSONRpcClient({
    'url': 'https://user-api.simplybook.me/login',
    'onerror': function (error) { },
});

I receive this message:

[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

For this reason, I can’ get the token.

Do you know how I have this warning?

Thanks!

Redmine Admin wrote:

Hi, please provide us raw http request

David Saenz wrote:

Redmine Admin wrote:

Hi, please provide us raw http request

General
Request URL: https://user-api.simplybook.me/login
Request Method: GET
Status Code: 200
Remote Address: 158.69.26.11:443
Referrer Policy: no-referrer-when-downgrade

Response header
access-control-allow-headers: content-type, x-company-login, x-application-token, x-user-token, x-token, x-requested-with
access-control-allow-methods: POST, GET, OPTIONS
access-control-allow-origin: *
content-encoding: gzip
content-type: application/json
date: Wed, 17 Oct 2018 14:48:39 GMT
server: nginx
status: 200
vary: Accept-Encoding
x-xss-protection: 1; mode=block
Provisional headers are shown

Provisional header are shown
Accept: /
Origin: http://dev.etronroom:3000
Referer: http://dev.etronroom:3000/booking
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36

And this is the response:

{  
   "transport":"POST",
   "envelope":"JSON-RPC-2.0",
   "contentType":"application\/json",
   "SMDVersion":"2.0",
   "target":"\/login",
   "services":{  
      "getServiceUrl":{  
         "envelope":"JSON-RPC-2.0",
         "transport":"POST",
         "parameters":[  
            {  
               "type":"object",
               "name":"companyLogin",
               "optional":false
            }
         ],
         "returns":"object"
      },
      "getToken":{  
         "envelope":"JSON-RPC-2.0",
         "transport":"POST",
         "parameters":[  
            {  
               "type":"object",
               "name":"companyLogin",
               "optional":false
            },
            {  
               "type":"object",
               "name":"apiKey",
               "optional":false
            }
         ],
         "returns":"object"
      },
      "getUserToken":{  
         "envelope":"JSON-RPC-2.0",
         "transport":"POST",
         "parameters":[  
            {  
               "type":"object",
               "name":"companyLogin",
               "optional":false
            },
            {  
               "type":"object",
               "name":"userLogin",
               "optional":false
            },
            {  
               "type":"object",
               "name":"userPassword",
               "optional":false
            }
         ],
         "returns":"object"
      },
      "getApplicationToken":{  
         "envelope":"JSON-RPC-2.0",
         "transport":"POST",
         "parameters":[  
            {  
               "type":"object",
               "name":"applicationApiKey",
               "optional":false
            }
         ],
         "returns":"object"
      }
   },
   "methods":{  
      "getServiceUrl":{  
         "envelope":"JSON-RPC-2.0",
         "transport":"POST",
         "parameters":[  
            {  
               "type":"object",
               "name":"companyLogin",
               "optional":false
            }
         ],
         "returns":"object"
      },
      "getToken":{  
         "envelope":"JSON-RPC-2.0",
         "transport":"POST",
         "parameters":[  
            {  
               "type":"object",
               "name":"companyLogin",
               "optional":false
            },
            {  
               "type":"object",
               "name":"apiKey",
               "optional":false
            }
         ],
         "returns":"object"
      },
      "getUserToken":{  
         "envelope":"JSON-RPC-2.0",
         "transport":"POST",
         "parameters":[  
            {  
               "type":"object",
               "name":"companyLogin",
               "optional":false
            },
            {  
               "type":"object",
               "name":"userLogin",
               "optional":false
            },
            {  
               "type":"object",
               "name":"userPassword",
               "optional":false
            }
         ],
         "returns":"object"
      },
      "getApplicationToken":{  
         "envelope":"JSON-RPC-2.0",
         "transport":"POST",
         "parameters":[  
            {  
               "type":"object",
               "name":"applicationApiKey",
               "optional":false
            }
         ],
         "returns":"object"
      }
   }
}

Redmine Admin wrote:

We need your request. Something is wrong with it because you got content of https://user-api.simplybook.me/login as response

David Saenz wrote:

Redmine Admin wrote:

We need your request. Something is wrong with it because you got content of https://user-api.simplybook.me/login as response

Before the response code, I share with you the request.

General
Request URL: https://user-api.simplybook.me/login
Request Method: GET
Status Code: 200
Remote Address: 158.69.26.11:443
Referrer Policy: no-referrer-when-downgrade

Response header
access-control-allow-headers: content-type, x-company-login, x-application-token, x-user-token, x-token, x-requested-with
access-control-allow-methods: POST, GET, OPTIONS
access-control-allow-origin: *
content-encoding: gzip
content-type: application/json
date: Wed, 17 Oct 2018 14:48:39 GMT
server: nginx
status: 200
vary: Accept-Encoding
x-xss-protection: 1; mode=block
Provisional headers are shown

Provisional header are shown
Accept: /
Origin: http://dev.etronroom:3000
Referer: http://dev.etronroom:3000/booking
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36

Redmine Admin wrote:

you just trying to get URL, it is not JSON RPC method call

David Saenz wrote:

Redmine Admin wrote:

you just trying to get URL, it is not JSON RPC method call

Sorry, I don’t undertand what do you need.
If I go to https://user-api.simplybook.me/login in my browser I receive the response code.

Can you give me more details in your request?

Dmytro Bondarev wrote:

Hi! You are making synchronous requests in your javascript. It does not relate to API.
If you use json rpc client from example please pass callback function when you call API method as last parameter.

David Saenz wrote:

Dmitry Bondarev wrote:

Hi! You are making synchronous requests in your javascript. It does not relate to API.
If you use json rpc client from example please pass callback function when you call API method as last parameter.

The fact is that I’m not even calling any method.
I am simply making the call as indicated in the example.

The object instance ‘JSONRpcClient’ is as indicated in the documentation and the object ‘JSONRpcClient’ is the example.

I do not even make the call to getToken, the error is in the “new JSONRpcClient”.

Dmytro Bondarev wrote:

The fact is that I’m not even calling any method.
I am simply making the call as indicated in the example.

So you are calling method. Please call it asynchronous.

Feel free to ask any questions related to API.

David Saenz wrote:

Dmitry Bondarev wrote:

The fact is that I’m not even calling any method.
I am simply making the call as indicated in the example.

So you are calling method. Please call it asynchronous.

Feel free to ask any questions related to API.

Ok, no problem.
Is just a warning.

I have another doubt of super novice,

What is unitId ?

Dmytro Bondarev wrote:

It is provider id.
You can get providers list by getUnitList API method.