Skip to content

Commit

Permalink
Converts filter output to match expected query string for questions
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Nov 30, 2018
1 parent 839d9dd commit 9d975f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/resources/question.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ it('can get questions with additional parameters', async () => {
expect(mockAxios.get).toHaveBeenCalledTimes(1);
expect(mockAxios.get).toHaveBeenCalledWith('questions', {
params: {
filters: {
service: 3,
},
'filter[service]': 3,
limit: 5,
page: 1,
sort: 'created',
Expand Down
5 changes: 3 additions & 2 deletions src/resources/question.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AxiosInstance } from 'axios';

import { combine } from '../helpers/filters';
import { Filterable, Pageable } from '../index';

export interface QuestionFilter {
Expand Down Expand Up @@ -37,10 +38,10 @@ export default class Question implements QuestionResource {

public async get(): Promise<any> {
const parameters = this.params();
const params: Filterable<QuestionParameters> = {};
let params: Filterable<QuestionParameters> = {};

if (Object.keys(parameters).length) {
params.filters = parameters;
params = combine(params, parameters);
}

if (this.limit) {
Expand Down

0 comments on commit 9d975f4

Please sign in to comment.