Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async fetchShas() {
const { owner, repo, deployments } = this.state;
this.startLoad('shas');
try {
const res = await ky
.post('/shas', { json: { owner, repo, deployments } })
.json();
if (res.error) {
this.setState({ error: res.error });
} else {
this.setState({
deployInfo: res.deployments,
tags: res.tags
});
}
} catch (error) {
console.warn('Error fetching shas!');
console.error(error);
this.setState({ error });
} finally {
async fetchFor(longUrl) {
const { url: shortUrl } = await ky
.post('/shortenit', { json: { url: longUrl } })
.json();
shortUrls.addShortUrl(shortUrl);
return shortUrl;
},
async fetchCulprits() {
const { owner, repo, deployInfo } = this.props;
this.setState({ loading: true });
const { signal } = this.controller;
try {
const res = await ky
.post('/culprits', {
signal,
json: { owner, repo, deployments: deployInfo }
})
.json();
if (this.dismounted) return;
if (res.error) {
this.setState({ error: res.error });
} else {
this.setState({ culprits: res.culprits });
}
} catch (error) {
if (this.dismounted) return;
this.setState({ error });
} finally {
if (this.dismounted) return;