Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Rest resource Shop.all() returns the complete response #1300

Closed
nullndr opened this issue Mar 27, 2024 · 3 comments · Fixed by #1318
Closed

Rest resource Shop.all() returns the complete response #1300

nullndr opened this issue Mar 27, 2024 · 3 comments · Fixed by #1318

Comments

@nullndr
Copy link

nullndr commented Mar 27, 2024

The call to admin.rest.resources.Shop.all({ session }) returns the whole response, and not just the data[0] object:

Like the Customer resurce, it should returns the following:

return response.data ? response.data[0] : null;
@nullndr
Copy link
Author

nullndr commented Mar 27, 2024

May I open a PR for this?

@paulomarg
Copy link
Contributor

Hi, thanks for raising this! This method is a bit of an odd one out because that API behaves a little different to the others.

Instead of changing the all method (which would be a breaking change), I wonder if it would be better to create a brand new method (Shop.current()?) that returns the first instance in data, similar to Customer.find().

I'll add this to our tracking, but to be transparent there are other things that would be done before this, so it might be a while before we can get to it. If you can open a PR, we'll be happy to review / merge it!

@nullndr
Copy link
Author

nullndr commented Apr 2, 2024

Hi @paulomarg, I do think that the use of Shop.all() is a bit confusioning to retrieve the store info, so I agree with the Shop.current() method.

I'll open a PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants