forked from arc53/DocsGPT
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from TaylorS15/taylor-working
bug fix
- Loading branch information
Showing
2 changed files
with
44 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
import { Doc } from '../models/misc'; | ||
|
||
export async function getDocs(): Promise<Array<Doc>> { | ||
//Fetch default source docs | ||
const response = await fetch( | ||
'https://d3dg1063dc54p9.cloudfront.net/combined.json', | ||
); | ||
const data = await response.json(); | ||
export async function getDocs(): Promise<Array<Doc> | null> { | ||
try { | ||
//Fetch default source docs | ||
const response = await fetch( | ||
'https://d3dg1063dc54p9.cloudfront.net/combined.json', | ||
); | ||
const data = await response.json(); | ||
|
||
//Create array of Doc objects | ||
const docs: Array<Doc> = []; | ||
//Create array of Doc objects | ||
const docs: Array<Doc> = []; | ||
|
||
data.forEach((doc: Doc) => { | ||
docs.push(doc); | ||
}); | ||
data.forEach((doc: Doc) => { | ||
docs.push(doc); | ||
}); | ||
|
||
return docs; | ||
return docs; | ||
} catch (error) { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters