-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(version-picker): reintroduce the version picker for storybook
- add better error handling for failed requests - add mock data as a fallback for testing purposes - add the version picker addon back into the storybook manager
- Loading branch information
1 parent
d83f547
commit 9d8ccf0
Showing
4 changed files
with
729 additions
and
9 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
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,15 +1,28 @@ | ||
import mockData from "./mock-data/metadata.json"; | ||
|
||
interface Metadata { | ||
versions: Record<string, string>; | ||
} | ||
|
||
const fetchData = async () => { | ||
const response = await fetch( | ||
"https://carbon.sage.com/metadata/metadata.json" | ||
); | ||
const fetchData = async (): Promise<Metadata | null> => { | ||
try { | ||
const response = await fetch( | ||
"https://carbon.sage.com/metadata/metadata.json" | ||
); | ||
|
||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
|
||
const metadata: Metadata = await response.json(); | ||
|
||
const metadata: Metadata = await response.json(); | ||
return metadata; | ||
} catch (error) { | ||
console.error("Failed to fetch metadata:", error); | ||
|
||
return metadata; | ||
console.log("Returning mock data as fallback"); | ||
return mockData as Metadata; | ||
} | ||
}; | ||
|
||
export default fetchData; |
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
Oops, something went wrong.