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 getUserId(accessToken) {
const response = await axios.get(
getUserInfo(accessToken),
{ headers: { Authorization: `Bearer ${accessToken}` } }
);
console.log(response);
return response.data["email"];
}
async function fetch(url) {
const response = await axios.get(url);
return response.data;
}
module.exports = function () {
return axios.get('https://www.thriveagric.com/#our-farms').then(res => {
const $ = cheerio.load(res.data)
fs.writeFileSync(thriveAgricHtml, res.data)
const activeProducts = $('li.product.type-product').filter(function () {
return $(this).find('span.out-of-stock-button').length == 0
})
const productList = activeProducts.map(function () {
const title = $(this).find('h6[itemprop="name"]').text().trim()
const price = $(this).find('span.woocommerce-Price-amount.amount').text().trim()
const link = $(this).find('a.product-category.product-info').attr('href').trim()
return { title, price, link }
}).toArray()
return productList
resolveCulture(id: string) {
return this.exec(Axios.get(BASE_URL + 'ResolveCulture', { params: { id } }))
.then((value) => this.processPayload(value));
}
verify() {
let onSuccess = (res: AxiosResponse) => {
let payload: IPayload = res.data;
if (payload.message.messageTypeId === PayloadMessageTypes.success) {
return payload.data;
} else {
throw new Error(payload.message.text);
}
}
return Axios.get(VERIFICATION_CODE_URL)
.then(onSuccess);
}
}
async function getNumberOfSoftwarePages() {
const r = await axios.get(`https://devpost.com/software/newest`);
const $ = cheerio.load(r.data);
return parseInt($('li.next.next_page').prev().text());
}
module.exports = function () {
return axios.get('https://www.farmcrowdy.com/farmshop').then(res => {
const $ = cheerio.load(res.data)
fs.writeFileSync(farmCrowdyHtml, res.data)
const activeProducts = $('div.project').filter(function () {
return $(this).find('div.project-image a span strong').length == 0
})
const productList = activeProducts.map(function () {
const title = $(this).find('div.project-content h5').text().trim()
const price = $(this).find('div.project-content span').text().trim()
const link = $(this).find('div.project-image a').attr('href').trim()
const returns = $(this).find('div.project-content p').text().trim()
return { title, price, link, returns }
}).toArray()
app.post('/:customerId/invoices/', (req, res) => {
if (!req.params.customerId)
return res.status(400).send("CustomerID hasn't been provided");
axios.get(`http://customers:3000/${req.params.customerId}`, { headers: { "apikey": "userKey" } }).then(
(response) => {
if (response.data.length === 0)
return res.status(404).send("No customer found");
req.body.customer = req.params.customerId;
Invoice.create(req.body)
.then((entity) => res.status(201).send({ id: entity._id }))
.catch((err) => res.status(500).send(err));
},
(err) => res.status(err.response.status || 500).send(err.message || err.code));
});
const getServiceStatus = async (key, service) => {
try {
const response = await axios.get(service.url, {timeout: 10000,})
return { service: key, up: true }
}
catch (e) {
return { service: key, up: false }
}
}
async function getSoftwareLinks(pageNum) {
const r = await axios.get(`https://devpost.com/software/newest?page=${pageNum}`);
const $ = cheerio.load(r.data);
const links = $('a.link-to-software').map((i, element) => {
return {
'href': $(element).attr('href'),
'projectSlug': $(element).attr('href').replace('https://devpost.com/software/', ''),
};
}).get();
return links;
}