Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
auth.get_twitter_bearer_token().then(function (bearer_token) {
// request options
var request_options = {
url: 'https://api.twitter.com/1.1/account_activity/all/count.json',
auth: {
'bearer': bearer_token
}
}
request.get(request_options).then(function (body) {
console.log(body)
})
})
auth.get_twitter_bearer_token().then(function (bearer_token) {
// request options
var request_options = {
url: 'https://api.twitter.com/1.1/account_activity/all/' + args.environment + '/subscriptions/list.json',
auth: {
'bearer': bearer_token
}
}
console.log(request_options)
request.get(request_options).then(function (body) {
console.log(body)
})
})
public async getSolcByUrlAndCache(fileName) {
const url = this.config.compilerUrlRoot + fileName;
// const spinner = ora({
// color: 'red',
// text: 'Downloading compiler',
// }).start();
try {
const response = await request.get(url);
// spinner.stop();
this.addFileToCache(response, fileName);
return this.compilerFromString(response);
} catch (error) {
// spinner.stop();
throw this.errors('noRequest', url, error);
}
}
new Promise((resolve, reject) =>
request.get({url: `${rootUrl}/statuses/user_timeline.json?user_id=${userId}&count=${count}`, oauth})
.then((response) => resolve(response))
.catch((err) => reject(err))
)
const bus_health = (service) => {
const request = require('request-promise');
return request
.get({ uri: `http://${service}:8080/health`, json: true })
.then((response) => {
console.log('in then');
return response;
})
.catch((error) => {
console.log('in catch');
throw error;
});
};
const request = (url, locale) => {
return requestPromise.get(url)
.then(res => {
if (res.length) {
const pathToFile = path.join(LOCALES_DIR, locale + '.json');
return writeInFile(pathToFile, res);
}
return null;
})
.then(res => locale += res ? ' - OK' : ' - Empty')
.catch(err => {
console.log(err);
return locale + ' - Not OK';
});
};
public static async callAPI(
path: string,
qs?: object
): Promise> {
const requestOptions = StatusAPIClient.buildRequestOptions(path, qs);
try {
const response = await request.get(requestOptions);
const parsedResponse: IResult = JSON.parse(response);
return parsedResponse;
} catch (error) {
throw new ApiError(error);
}
}
request.head(downloadUrl, error => {
if (error) {
return reject(error);
}
request
.get(downloadUrl)
.pipe(fs.createWriteStream(filename))
.on('close', () => {
return resolve();
});
});
});
'titles=Image:' + name + '&' +
'prop=imageinfo&' +
'iiprop=url&' +
'iiurlwidth=' + width + '&' +
'format=json';
const apiHeaders = {
'User-Agent' : 'https://machinelearningforkids.co.uk',
'Accept': 'application/json',
};
const options = {
headers : apiHeaders,
json : true,
};
const body = await request.get(apiUrl, options);
return body;
}