Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toHref(resourcePath, previousLocation) {
const resourcePathParts = resourcePath.split('/');
return previousLocation.pathname + '?' + param(
{...previousLocation.query, version: resourcePathParts[4], history: true}
);
}
}
param(data) {
return param(data);
}
export default () => {
const query = 'burger';
const latitude = '37.773972';
const longitude = '-122.431297';
const params = param({
v: '20161016',
ll: [latitude, longitude].join(','),
query,
limit: 15,
intent: 'checkin',
client_id: 'BCUJZ2MSKUWJC2Q5HVIYZLHRWGFJ2OFPKPLBP1NOBNR3VW5R',
client_secret: 'Q10HUP5APBQOYNTPABSH4CSKRGEAI2CXIYULYGG0EZYUUWUZ',
});
return fetch(`https://api.foursquare.com/v2/venues/search?${params}`)
.then(res => res.json())
.then(data => ({
venues: data.response.venues,
latitude,
longitude,
query,
export default function(url, path, queryParams) {
let query = param(queryParams);
let pathUrl = url.charAt(url.length - 1) === '/' ? `${url}${path}` : `${url}/${path}`;
return query ? `${pathUrl}?${query}` : pathUrl;
}
function fetchItemsForFilter(tag, filter = '', limit = '') {
let params = '';
if (filter || limit) {
params = param({filter, limit});
}
return {
[RSAA]:{
types: [
ITEMS_FOR_FILTER_JOBS_REQUEST,
{
type: ITEMS_FOR_FILTER_JOBS_SUCCESS,
meta: {tag}
},
ITEMS_FOR_FILTER_JOBS_FAILURE
],
method: 'GET',
endpoint: `${API_URL_V2}/jobs/filters/${tag}${params}`
}
};
}
export function solveUrl (url, data) {
let queryString = param(data);
return url + (url.indexOf('?') >= 0 ? '&' : '?') + queryString;
}