0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Limited the keys pulled from Settings API

refs https://github.com/TryGhost/Team/issues/3009

- It's best to pull in as much data from the API as the app's state will ever use. Makes it explicit about what fields the app depends on instead of requesting a whole of "settings"
This commit is contained in:
Naz 2023-04-19 17:49:32 +02:00 committed by Elena Baidakova
parent 7270c17a1d
commit 5421ab5ab0

View file

@ -1,7 +1,7 @@
function setupGhostApi({apiUrl, apiKey}) {
function contentEndpointFor({resource, params = ''}) {
function contentEndpointFor({resource, keys, params = ''}) {
if (apiUrl && apiKey) {
return `${apiUrl.replace(/\/$/, '')}/${resource}/?key=${apiKey}&limit=all${params}`;
return `${apiUrl.replace(/\/$/, '')}/${resource}/?key=${apiKey}&keys=${keys.join(',')}${params}`;
}
return '';
}
@ -19,7 +19,10 @@ function setupGhostApi({apiUrl, apiKey}) {
api.site = {
settings() {
const url = contentEndpointFor({resource: 'settings'});
const url = contentEndpointFor({
resource: 'settings',
keys: ['announcement', 'announcement_background']
});
return makeRequest({
url,
method: 'GET',