Browse Source

Handle potential error when converting res to JSON

master
Leo Lamprecht 8 years ago
parent
commit
5e5545789f
No known key found for this signature in database GPG Key ID: B08517883D5E0E10
  1. 9
      lib/github.js

9
lib/github.js

@ -12,22 +12,23 @@ import {error} from './error'
const exists = async repoPath => {
const apiURL = `https://api.github.com/repos/${repoPath}`
let request
let response
try {
request = await fetch(apiURL)
response = await request.json()
} catch (err) {
error(`Not able to check if repo exists - ${err.message}`)
return false
}
const res = await request.json()
if (!res.name) {
if (!response.name) {
return false
}
return res
return response
}
const downloadRepo = async repoPath => {

Loading…
Cancel
Save