You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
638 B

import fetch from 'node-fetch';
import { unix, get_credentials } from '../util.mjs';
export const update_last_scraped = async (place, prod = false) => {
const { api, token } = get_credentials(prod);
let res = await fetch(`${api}/places/${place.id}/?token=${token}`, {
method: 'PATCH',
body: JSON.stringify({
last_scraped: unix(new Date())
}),
headers: { 'Content-Type': 'application/json' }
});
if (res.ok) {
console.log(res.status, `Last scrape at ${place.name} updated.`);
} else {
console.log(
res.status,
`Last scrape at ${place.name} failed to update last update..`
);
}
};