cerialize icon indicating copy to clipboard operation
cerialize copied to clipboard

is it works with HttpClient ?

Open Calion54 opened this issue 5 years ago • 3 comments

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 ???

Calion54 avatar Oct 25 '18 11:10 Calion54

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

weichx avatar Nov 07 '18 08:11 weichx

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

you can close close the issue now

adsau59 avatar Dec 18 '18 07:12 adsau59

@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)));
}

prudnikov avatar Mar 17 '19 00:03 prudnikov