Comment 'Hello!Example of the...' to 'Dolphin TO Una developper'
  • Hello!

    Example of the code how to get information about the logged member using /me link from React using axios lib.

    return axios.get('https://yourdomain/m/oauth2/api/me',
    {
        headers: {
            'Authorization': 'Bearer your_bearer_code',
            'Content-Type': 'application/json'
        }    
    })
    .then(response => {})

    If you like to call method from any module from allowed list from description here https://github.com/unaio/una/wiki/Dev-API you may use something like this:

    For example: to call market method to check product license BxMarketModule::serviceHasLicense ($iProfileId, $iProductId, $sDomain = '')

    const oData = {
        method:'has_license',
        module:'bx_market',
        params:[iProfileId, iProductId,sDomain]
    };
    
    const sUrl = `https://yourdomain/m/oauth2/api/service?method=${oData['method']}&module=${oData['module']}&params[]=${oData['params'][0]}&params[]=${oData['params'][1]}&params[]=${oData['params'][2]}`;
    
    return (dispatch) => {
        return axios.get(sUrl,
            {
                headers: {
                    'Authorization': 'Bearer you_barear',
                    'Content-Type': 'application/json'
                },
            }).then(response => {});
    }