Skip to content

Commit

Permalink
Sends token during details call instead of just removing it
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Aug 22, 2019
1 parent 9a3fb52 commit 2273253
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/resources/location.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ it('can fetch details for a given location identifier received from a suggestion
await resource.details('random_string_of_characters');

expect(mockAxios.get).toHaveBeenCalledTimes(1);
expect(mockAxios.get).toHaveBeenCalledWith('location-details/random_string_of_characters');
expect(mockAxios.get).toHaveBeenCalledWith('location-details/random_string_of_characters', {
headers: {
'x-location-details-token': 'value',
},
});
expect(sessionStorage.getItem(STORAGE_KEY)).toBeNull();
});
6 changes: 5 additions & 1 deletion src/resources/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ export default class Location extends Conditional implements LocationResource {
}

public async details(identifier: string): Promise<any> {
const headers = {
'x-location-details-token': retrieve(),
};

remove();

return await this.client.get(`location-details/${identifier}`);
return await this.client.get(`location-details/${identifier}`, { headers });
}

public async get(): Promise<any> {
Expand Down

0 comments on commit 2273253

Please sign in to comment.