Skip to content

Exception is thrown when invalid api_key is passed #1

@nikiatanasow

Description

@nikiatanasow

Description

If you pass invalid api_key to the place object and try to make a request an exception is thrown.

Steps to Reproduce

  • Set invalid access token to the place object (for example test_private_key_invalid_value).
  • try to make any request.

Expected Behavior

The promise should be rejected.

Actual Behavior

Exception is thrown. The exception cannot be catched.

Code snipped that reproduce the issue:

const place = require('place-api');
place.api_key = 'test_private_key_invalid_value';

try {
    var account = place.Account.get()
        .then(function(account) {
            console.log(account)
        }).catch(function(error) {
            console.log(error);
    });
} catch (error) {
    console.log(error);
}

Output:

Unauthorized: api_sessions
    at Request._callback (/Users/atanasov/Desktop/work/place-test/node_modules/place-api/lib/APIResource.js:138:31)
    at Request.self.callback (/Users/atanasov/Desktop/work/place-test/node_modules/request/request.js:185:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/Users/atanasov/Desktop/work/place-test/node_modules/request/request.js:1161:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/Users/atanasov/Desktop/work/place-test/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions