-
Notifications
You must be signed in to change notification settings - Fork 219
Create a constants.js file with the NAMESPACE value #799
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the namespace for the API actually wc/blocks
? wc/blocks/products
is an endpoint - and there is no guarantee we won't have other endpoints using the wc/blocks
namespace in the future.
This is a good point. With that in mind, I wonder if it'd be better to create an const ENDPOINTS = {
root: 'wc/blocks',
products: 'wc/blocks/products'
}; That retains flexibility for future additional endpoints? Also, an education type question I have... are these endpoints part of a versioned api? If not, should they be? When I do a request to |
@nerrad since it's a private API (now) we don't need to version--blocks is the only consumer on this API. The core version is being removed in 3.7. |
bdc8372
to
edb14d5
Compare
Thanks for the reviews @mikejolley @nerrad. I replaced the This PR is ready for another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pre-approving because it's fine as is, but I do have a minor tweak to my original suggestion that I think is worth considering.
export const ENDPOINTS = { | ||
root: '/wc/blocks', | ||
products: '/wc/blocks/products', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I know this is following my initial suggestion but I'm wondering if we should do something like this instead:
const NAMESPACE = '/wc/blocks';
export const ENDPOINTS = {
root: NAMESPACE,
products: `${ NAMESPACE }/products`,
};
- reduces chance of typo errors for the namespace on future endpoints added.
- easier swapping out of namespace (albeit search and replace is arguably just as easy).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in f727482.
This PR creates a
constants.js
file as discussed here: #779 (comment).How to test the changes in this Pull Request:
Creating a new post, adding the affected blocks and verifying they still fetch information should be enough to test.
Affected blocks:
Changelog