Skip to content

Commit

Permalink
fix(entityService): remove trailing / at end of endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
escarre committed May 30, 2018
1 parent bfbe030 commit 06fa5fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/core/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class Entity<T extends Identity> extends StatefulSubject<T> {
super(state);
this.type = type;
this.$entity = new EntityService<T>(this.type);
observeOptions(options).subscribe((params) => {
observeOptions(options).subscribe(params => {
if (!params) {
return;
}
Expand Down Expand Up @@ -221,7 +221,7 @@ export class Entity<T extends Identity> extends StatefulSubject<T> {
if (!state || !state.id) {
return;
}
this.broker.on(`${this.type}:${state.id}:value`).subscribe((value) => {
this.broker.on(`${this.type}:${state.id}:value`).subscribe(value => {
this.patch(value, true);
});
}
Expand Down
11 changes: 4 additions & 7 deletions src/services/EntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export class EntityService<T> {
*/
constructor(type: string) {
this.type = type;
this.endpoint = `entity/${this.type}/`;
this.endpoint = `entity/${this.type}`;
this.http = Staffing.http();
this.meta = new MetaService(this.type);
this.parameters = {
fields: this._fields || ['id']
fields: this._fields || ['id'],
};
}

Expand Down Expand Up @@ -72,10 +72,7 @@ export class EntityService<T> {
* @param id - Id of the Model to retrieve
*/
async get(id: number): Promise<BullhornEntityResponse<T>> {
const [response, meta] = await Promise.all([
this.http.get(`${this.endpoint}${id}`, { params: this.parameters }),
this.meta.getFull(this.parameters.fields, this.parameters.layout)
]);
const [response, meta] = await Promise.all([this.http.get(`${this.endpoint}/${id}`, { params: this.parameters }), this.meta.getFull(this.parameters.fields, this.parameters.layout)]);
const result: BullhornEntityResponse<T> = response.data;
result.meta = meta;
return result;
Expand Down Expand Up @@ -117,7 +114,7 @@ export class EntityService<T> {
async save(value: any): Promise<AxiosResponse> {
// Update
if (value && value.id) {
return this.http.post(`${this.endpoint}${value.id}`, value);
return this.http.post(`${this.endpoint}/${value.id}`, value);
}
// Create
return this.http.put(this.endpoint, value);
Expand Down

0 comments on commit 06fa5fa

Please sign in to comment.