Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
client better error handliing
Browse files Browse the repository at this point in the history
  • Loading branch information
RusAlex committed Oct 16, 2016
1 parent a9b52b6 commit 33b6b9c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/api/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,17 @@ export default class ApiClient
}

async getAvailableUsername(username) {
let json;
const response = await this.get(`/api/v1/user/available-username/${username}`);
const json = await response.json();

if (!response.ok) {
json = await response.json();
const error = json.error || response.statusText;
throw new Error(error);
}

json = await response.json();

return json.username;
}

Expand Down

0 comments on commit 33b6b9c

Please sign in to comment.