Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it works with HttpClient ? #92

Open
Calion54 opened this issue Oct 25, 2018 · 3 comments
Open

is it works with HttpClient ? #92

Calion54 opened this issue Oct 25, 2018 · 3 comments

Comments

@Calion54
Copy link

Hi,
I'm using HttpClient from Angular 6 and I would like to use your librairie to transform snakecase to camelcase but it's doesn't works...

My Model :

export class Set {
  @autoserializeAs('set_id') setId: string;
  @serialize year: number;
  @serialize number: number;
  @serialize theme: string;
  @serialize name: string;
  @serialize image: string;
}

My service :

  getSet(setId): Observable<Set> {
    return this.httpClient.get<Set>(this.setsUrl + setId + '/');
  }

is it possible or not ???

@weichx
Copy link
Owner

weichx commented Nov 7, 2018

I don't know anything about HttpClient or Angular but I don't see why it wouldn't work. You probably need to actually call Serialize/Deserialize though, your sample doesn't invoke Cerialize

@adsau59
Copy link

adsau59 commented Dec 18, 2018

it works, amazing script dude keep up the good work 😄

you can close close the issue now

@prudnikov
Copy link

@Calion54 you can call map operator to deserialize. I suppose Set is you data class.

getSet(setId): Observable<Set> {
  return this.httpClient.get<JsonObject>(this.setsUrl + setId + '/')
    .pipe(map(data => Deserialize<Set>(data, Set)));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants