Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/api/kitePaint/__unit__/getDesign.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ describe("#getDesign", () => {
};
});
it("makes the relevant request", async () => {
expect.assertions(2);
await Api.getDesign("abc").catch(() => {});
expect(Api.axiosInstance.get.mock.calls[0][0]).toEqual("/designs.php");
expect(Api.axiosInstance.get.mock.calls[0][1]).toEqual({
params: {
id: "abc"
}
});
expect(Api.axiosInstance.get.mock.calls[0][0]).toEqual(
"/designs.php?filter%5Bid%5D=abc"
);
});
it("does not make identical requests when they have been cached", async () => {
expect.assertions(1);
Expand Down
11 changes: 8 additions & 3 deletions src/api/kitePaint/getDesign.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Qs from "qs";
import Design from "../../models/Design";
import { error } from "../../theme/Alert";

Expand All @@ -15,11 +16,15 @@ export default async function getDesign(id, useCache = true) {
return cache;
}
}
const response = await this.axiosInstance.get("/designs.php", {
params: {
const requestData = {
filter: {
id
}
});
};
const requestString = Qs.stringify(requestData);
const response = await this.axiosInstance.get(
`/designs.php?${requestString}`
);

// Handle invalid responses
if (!response.data || !response.data.length) {
Expand Down
Loading