Support rest and implement SignIn and SignUp Rest + Mutations

This commit is contained in:
Chi Vinh Le
2018-08-10 19:07:41 +02:00
parent 7cb5ab37a7
commit 1dec622e64
12 changed files with 95 additions and 14 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ const handleResp = (res: Response) => {
if (res.status > 399) {
return res.json().then((err: any) => {
// TODO: sync error handling with server.
const message = err.message || res.status;
const message = err.message || err.error || res.status;
const error = new Error(message);
throw error;
});
@@ -43,7 +43,7 @@ export class RestClient {
this.tokenGetter = tokenGetter;
}
public fetch(path: string, options: PartialRequestInit): Promise<Response> {
public fetch<T>(path: string, options: PartialRequestInit): Promise<T> {
let opts = options;
if (this.tokenGetter) {
opts = merge({}, options, {