Skip to content

[Bug]: trackerId response possible undefined? #32

Open
@termorey

Description

@termorey

Описание

Is response possible undefined?

if (response.active === MyTrackerStatus.ON) {

// current code
export class MyTrackerService {

  // current code
  public init() {
    this.getTrackerId()
      .then(({ response }) => {
        if (response.active === MyTrackerStatus.ON) { // response is undefined → error
          this.includeOnPage(response.tracker_id);
        }
      })
      .catch(console.error);
  }
  
}
// proposal code
export class MyTrackerService {

  // proposal code
  public init() {
    this.getTrackerId()
      .then(({ response }) => {
        // if (response.active === MyTrackerStatus.ON) { // response is undefined → error
        if (response && response.active === MyTrackerStatus.ON) {
          this.includeOnPage(response.tracker_id);
        }
      })
      .catch(console.error);
  }
  
}

Шаги воспроизведения

Run Config.init method

Версия vkid/sdk

2.4.0

В каких браузерах воспроизводится проблема?

Yandex Browser

Ожидаемое поведение

Response exists check

Скриншоты

image

Пример с воспроизведением

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions