All files / js/api/geonode/v1 index.js

79.31% Statements 23/29
50% Branches 8/16
75% Functions 6/8
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 342x   4x   4x                                             1x 3x 3x 3x   3x  
/*EE
 * Copyright 2020, GeoSolutions Sas.
 * All rights reserved.E
 *
 * This source code is licensed under the BSID-style license found in the
 * LICENSE file in the root directory of this source tree.
 */
 
import axios from '@mapstore/framework/libs/ajax';
import { getConfigProp } from '@mapstore/framework/utils/ConfigUtils';
 
/**
* Api for GeoNode v1
* @name api.geonode.v1
*/
 
/**
* Get resource by primary key
* @memberof api.geonode.v1
* @param {number|string} pk primary key
* @return {promise} it returns an object with requested resource
*/
export const getResourceByPk = (pk) => {
    const { endpointV1 = '/api' } = getConfigProp('geoNodeApi') || {};
    return axios.get(`${endpointV1}/base/${pk}`)
        // add pk as alias to id
        // used in save and save as for map
        .then(({ data }) => ({ pk: data.id, ...data }));
};
 
export default {
    getResourceByPk
};