Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function getData(query) {
let options = {
url: apiConfig.occurrenceSearch.url + '?' + querystring.stringify(query),
method: 'GET',
fullResponse: true,
json: true
};
let response = await request(options);
if (response.statusCode !== 200) {
// TODO log error
throw 'Internal server error getting data';
}
return response.body;
}
function get_gif(tags, func) {
var params = {"api_key": "dc6zaTOxFJmzC", "rating": "r", "format": "json","limit": 1 };
var query = qs.stringify(params);
if (tags !== null) {query += "&tag=" + tags.join('+')}
var request = require("request");
request("http://api.giphy.com/v1/gifs/random?" + query, function (error, response, body) {
if (error || response.statusCode !== 200) {bot.sendMessage(msg, "There was an error getting a gif");console.log(errorC(error));}
else {var responseObj = JSON.parse(body); func(responseObj.data.id);}
}.bind(this));
}
function createUrlFromEndpointAndOptions (endpoint, options) {
const query = qs.stringify(options);
const baseURL = `${host}${endpoint}`;
return query ? `${baseURL}?${query}` : baseURL;
}
post(url, data, options = {}) {
options.method = options.method || 'POST';
if ('object' === typeof data && undefined !== options.postType && 'json' === options.postType) {
data = JSON.stringify(data);
options.postContentType = options.postContentType || 'application/json';
} else if ('object' === typeof data) {
data = querystring.stringify(data);
}
options.postData = data;
return this.request(url, options);
}
get(path: string, query?: {}) {
let params = '';
if (query && Object.keys(query).length) {
params += '?' + querystring.stringify(query);
}
const headers = this.makeHeader('/v1'.concat(path, params));
return super.get(path, query, headers);
}
get: function (path, queryParams, userSecret) {
const headers = _getHeaders({ userSecret })
queryParams = querystring.stringify(queryParams)
return _dispatchAxiosRequest('GET', path + '?' + queryParams, headers, null)
},
export function ticketString({corpus, ...params}: KytheTicket) {
if (params.root === '') delete params.root;
return `kythe://${corpus}?` + stringify(params, '?') as KytheTicketString;
}
module.exports = function webmapUrl(location, params) {
if(params === undefined)
params = {}
var url = "https://www.arcgis.com/home/webmap/viewer.html"
if(params.marker === undefined || params.marker === null) {
params.marker = location.x + ";" + location.y + ";;Ping;;Ping";
}
if(params.level === undefined || params.level === null) {
params.level = 16;
}
return url + "?" + qs.stringify(params);
}
getAuthorizationUrl : function(params) {
params = _.extend({
response_type : "code",
client_id : this.clientId,
redirect_uri : this.redirectUri
}, params || {});
return this.authzServiceUrl +
(this.authzServiceUrl.indexOf('?') >= 0 ? "&" : "?") +
querystring.stringify(params);
},