Skip to main content
VS Code preview Full workbench mockup using this variant's colors and tokenColors.
colors Workbench UI color keys from the theme JSON colors map.
activityBar.activeBackground #262626 activityBar.activeBorder #CC0000 activityBar.background #1e1e1e activityBar.border #262626 activityBar.dropBorder #CC0000 activityBar.foreground #CC0000 tokenColors TextMate scopes and font styles (syntax highlighting rules).
scope foreground fontStyle comment, punctuation.definition.comment #546E7A italic variable, string constant.other.placeholder #EEFFFF — constant.other.color #ffffff — invalid, invalid.illegal #FF5370 — keyword, storage.type, storage.modifier
Shiki preview TypeScript sample highlighted with this variant's colors and tokenColors.
activityBar.inactiveForeground
#CCCCCC
activityBarBadge.background #CCCCCC
activityBarBadge.foreground #1e1e1e
badge.background #262626
badge.foreground #1e1e1e
breadcrumb.activeSelectionForeground #CCCCCC
breadcrumb.background #1e1e1e
breadcrumb.focusForeground #CC0000
breadcrumb.foreground #CCCCCC
breadcrumbPicker.background #1e1e1e
button.background #262626
button.foreground #CCCCCC
button.hoverBackground #1e1e1e
button.secondaryBackground #CCCCCC
button.secondaryForeground #1e1e1e
button.secondaryHoverBackground #eee5ce
charts.blue #75beff
charts.foreground #CCCCCC
charts.green #89d185
charts.lines #cccccc80
charts.orange #d18616
charts.purple #b180d7
charts.red #fb5245
charts.yellow #cca700
checkbox.background #1e1e1e
checkbox.border #262626
checkbox.foreground #CCCCCC
debugConsole.errorForeground #f48771
debugConsole.infoForeground #75beff
debugConsole.sourceForeground #cccccc
debugConsole.warningForeground #cca700
debugConsoleInputIcon.foreground #cccccc
debugExceptionWidget.background #420b0d
debugExceptionWidget.border #fb5245
debugIcon.breakpointCurrentStackframeForeground #ffcc00
debugIcon.breakpointDisabledForeground #848484
debugIcon.breakpointForeground #fb5245
debugIcon.breakpointStackframeForeground #89d185
debugIcon.breakpointUnverifiedForeground #848484
debugIcon.continueForeground #75beff
debugIcon.disconnectForeground #f48771
debugIcon.pauseForeground #75beff
debugIcon.restartForeground #89d185
debugIcon.startForeground #89d185
debugIcon.stepBackForeground #75beff
debugIcon.stepIntoForeground #75beff
debugIcon.stepOutForeground #75beff
debugIcon.stepOverForeground #75beff
debugIcon.stopForeground #f48771
debugTokenExpression.boolean #4e94ce
debugTokenExpression.error #f48771
debugTokenExpression.name #c586c0
debugTokenExpression.number #b5cea8
debugTokenExpression.string #ce9178
debugTokenExpression.value #cccccc99
debugToolBar.background #1e1e1e
debugView.exceptionLabelBackground #1e1e1e
debugView.exceptionLabelForeground #cccccc
debugView.stateLabelBackground #262626
debugView.stateLabelForeground #CCCCCC
debugView.valueChangedHighlight #1163a7
descriptionForeground #CCCCCC
diffEditor.diagonalFill #cccccc33
diffEditor.insertedTextBackground #9bb95533
diffEditor.removedTextBackground #ff000033
dropdown.background #1e1e1e
dropdown.border #262626
dropdown.foreground #CCCCCC
dropdown.listBackground #1e1e1e
editor.background #1e1e1e
editor.findMatchBackground #515c6a
editor.findMatchHighlightBackground #442b43
editor.findRangeHighlightBackground #3a3d4166
editor.focusedStackFrameHighlightBackground #7abd7a4d
editor.foldBackground #442b434d
editor.foreground #CCCCCC
editor.hoverHighlightBackground #264f7840
editor.inactiveSelectionBackground #442b4380
editor.lineHighlightBackground #262626
editor.lineHighlightBorder #282828
editor.rangeHighlightBackground #ffffff0b
editor.selectionBackground #442b43
editor.selectionHighlightBackground #38233799
editor.snippetFinalTabstopHighlightBorder #525252
editor.snippetTabstopHighlightBackground #7c7c7c4d
editor.stackFrameHighlightBackground #ffff0033
editor.symbolHighlightBackground #442b43
editor.wordHighlightBackground #575757b8
editor.wordHighlightStrongBackground #004972b8
editorBracketMatch.background #442b43
editorBracketMatch.border #262626
editorCodeLens.foreground #999999
editorCursor.foreground #81277e
editorError.foreground #f48771
editorGroup.border #444444
editorGroup.dropBackground #53595d80
editorGroupHeader.border #262626
editorGroupHeader.noTabsBackground #1e1e1e
editorGroupHeader.tabsBackground #1e1e1e
editorGutter.addedBackground #587c0c
editorGutter.background #1e1e1e
editorGutter.commentRangeForeground #c5c5c5
editorGutter.deletedBackground #94151b
editorGutter.foldingControlForeground #c5c5c5
editorGutter.modifiedBackground #0c7d9d
editorHint.foreground #eeeeeeb3
editorHoverWidget.background #1e1e1e
editorHoverWidget.border #262626
editorHoverWidget.foreground #CCCCCC
editorHoverWidget.statusBarBackground #1e1e1e
editorIndentGuide.activeBackground #e3e4e229
editorIndentGuide.background #262626
editorInfo.foreground #75beff
editorLightBulb.foreground #ffcc00
editorLightBulbAutoFix.foreground #75beff
editorLineNumber.activeForeground #c6c6c6
editorLineNumber.foreground #555049
editorLink.activeForeground #4e94ce
editorMarkerNavigation.background #2d2d30
editorMarkerNavigationError.background #f48771
editorMarkerNavigationInfo.background #75beff
editorMarkerNavigationWarning.background #cca700
editorOverviewRuler.addedForeground #587c0c99
editorOverviewRuler.border #7f7f7f4d
editorOverviewRuler.bracketMatchForeground #a0a0a0
editorOverviewRuler.commonContentForeground #60606066
editorOverviewRuler.currentContentForeground #40c8ae80
editorOverviewRuler.deletedForeground #94151b99
editorOverviewRuler.errorForeground #ff1212b3
editorOverviewRuler.findMatchForeground #d186167e
editorOverviewRuler.incomingContentForeground #40a6ff80
editorOverviewRuler.infoForeground #75beff
editorOverviewRuler.modifiedForeground #0c7d9d99
editorOverviewRuler.rangeHighlightForeground #007acc99
editorOverviewRuler.selectionHighlightForeground #a0a0a0cc
editorOverviewRuler.warningForeground #cca700
editorOverviewRuler.wordHighlightForeground #a0a0a0cc
editorOverviewRuler.wordHighlightStrongForeground #c0a0c0cc
editorPane.background #1e1e1e
editorRuler.foreground #5a5a5a
editorSuggestWidget.background #1e1e1e
editorSuggestWidget.border #262626
editorSuggestWidget.foreground #CCCCCC
editorSuggestWidget.highlightForeground #0097fb
editorSuggestWidget.selectedBackground #262626
editorUnnecessaryCode.opacity #000000aa
editorWarning.foreground #cca700
editorWhitespace.foreground #e3e4e229
editorWidget.background #252526
editorWidget.border #454545
editorWidget.foreground #cccccc
errorForeground #f48771
extensionBadge.remoteBackground #CCCCCC
extensionBadge.remoteForeground #1e1e1e
extensionButton.prominentBackground #327e36
extensionButton.prominentForeground #CCCCCC
extensionButton.prominentHoverBackground #28632b
focusBorder #262626
foreground #CCCCCC
gitDecoration.addedResourceForeground #629755
gitDecoration.conflictingResourceForeground #9876aa
gitDecoration.deletedResourceForeground #6c6c6c
gitDecoration.ignoredResourceForeground #7a725c
gitDecoration.modifiedResourceForeground #458588
gitDecoration.stageDeletedResourceForeground #6c6c6c
gitDecoration.stageModifiedResourceForeground #458588
gitDecoration.submoduleResourceForeground #458588
gitDecoration.untrackedResourceForeground #d1675a
icon.foreground #CCCCCC
input.background #262626
input.border #262626
input.foreground #CCCCCC
input.placeholderForeground #CCCCCC9d
inputOption.activeBackground #1e1e1e
inputOption.activeBorder #CC0000
inputOption.activeForeground #CCCCCC
inputValidation.errorBackground #5a1d1d
inputValidation.errorBorder #be1100
inputValidation.infoBackground #063b49
inputValidation.infoBorder #007acc
inputValidation.warningBackground #352a05
inputValidation.warningBorder #b89500
list.activeSelectionBackground #262626
list.activeSelectionForeground #CCCCCC
list.deemphasizedForeground #8c8c8c
list.dropBackground #062f4a
list.errorForeground #f88070
list.filterMatchBackground #442b43
list.focusBackground #262626
list.highlightForeground #0097fb
list.hoverBackground #2a2d2e
list.inactiveSelectionBackground #37373d
list.invalidItemForeground #b89500
list.warningForeground #cca700
listFilterWidget.background #653723
listFilterWidget.noMatchesOutline #be1100
listFilterWidget.outline #00000000
menu.background #1e1e1e
menu.border #262626
menu.foreground #CCCCCC
menu.selectionBackground #262626
menu.selectionBorder #CC0000
menu.selectionForeground #CCCCCC
menu.separatorBackground #bbbbbb
menubar.selectionBackground #262626
menubar.selectionBorder #1e1e1e
menubar.selectionForeground #cccccc
merge.commonContentBackground #60606029
merge.commonHeaderBackground #60606066
merge.currentContentBackground #40c8ae33
merge.currentHeaderBackground #40c8ae80
merge.incomingContentBackground #40a6ff33
merge.incomingHeaderBackground #40a6ff80
minimap.background #1e1e1e
minimap.errorHighlight #ff1212b3
minimap.findMatchHighlight #d18616
minimap.selectionHighlight #264f78
minimap.warningHighlight #cca700
minimapGutter.addedBackground #587c0c
minimapGutter.deletedBackground #94151b
minimapGutter.modifiedBackground #0c7d9d
minimapSlider.activeBackground #bfbfbf33
minimapSlider.background #26262680
minimapSlider.hoverBackground #64646459
notebook.cellBorderColor #26262666
notebook.cellHoverBackground #26262633
notebook.cellInsertionIndicator #007fd4
notebook.cellStatusBarItemHoverBackground #ffffff26
notebook.cellToolbarSeparator #80808059
notebook.focusedCellBackground #26262666
notebook.focusedCellBorder #ffffff1f
notebook.focusedEditorBorder #007fd4
notebook.outputContainerBackgroundColor #26262666
notebook.symbolHighlightBackground #ffffff0b
notebookScrollbarSlider.activeBackground #bfbfbf66
notebookScrollbarSlider.background #262626
notebookScrollbarSlider.hoverBackground #646464b3
notebookStatusErrorIcon.foreground #f48771
notebookStatusRunningIcon.foreground #cccccc
notebookStatusSuccessIcon.foreground #89d185
notificationCenter.border #CC0000
notificationCenterHeader.background #262626
notificationCenterHeader.foreground #CCCCCC
notificationLink.foreground #CCCCCC
notifications.background #252526
notifications.border #262626
notifications.foreground #cccccc
notificationsErrorIcon.foreground #f48771
notificationsInfoIcon.foreground #75beff
notificationsWarningIcon.foreground #cca700
panel.background #1e1e1e
panel.border #262626
panel.dropBorder #CCCCCC
panelSection.border #262626
panelSection.dropBackground #53595d80
panelSectionHeader.background #80808033
panelTitle.activeBorder #CC0000
panelTitle.activeForeground #CCCCCC
panelTitle.inactiveForeground #CCCCCC
peekView.border #3187c0
peekViewEditor.background #001f33
peekViewEditor.matchHighlightBackground #ff8f0099
peekViewEditorGutter.background #001f33
peekViewResult.background #252526
peekViewResult.fileForeground #ffffff
peekViewResult.lineForeground #bbbbbb
peekViewResult.matchHighlightBackground #ea5c004d
peekViewResult.selectionBackground #3399ff33
peekViewResult.selectionForeground #ffffff
peekViewTitle.background #1e1e1e
peekViewTitleDescription.foreground #ccccccb3
peekViewTitleLabel.foreground #ffffff
pickerGroup.border #262626
pickerGroup.foreground #CC0000
problemsErrorIcon.foreground #f48771
problemsInfoIcon.foreground #75beff
problemsWarningIcon.foreground #cca700
progressBar.background #262626
quickInput.background #1e1e1e
quickInput.foreground #CCCCCC
quickInputTitle.background #ffffff1b
scm.providerBorder #454545
scrollbar.shadow #00000000
scrollbarSlider.activeBackground #bfbfbf66
scrollbarSlider.background #262626
scrollbarSlider.hoverBackground #646464b3
searchEditor.findMatchBackground #442b43a8
searchEditor.findMatchBorder #442b43
searchEditor.textInputBorder #262626
selection.background #442b43
settings.checkboxBackground #1e1e1e
settings.checkboxBorder #262626
settings.checkboxForeground #CCCCCC
settings.dropdownBackground #1e1e1e
settings.dropdownBorder #262626
settings.dropdownForeground #CCCCCC
settings.dropdownListBorder #454545
settings.focusedRowBackground #262626
settings.headerForeground #CCCCCC
settings.modifiedItemIndicator #CC0000
settings.numberInputBackground #262626
settings.numberInputBorder #262626
settings.numberInputForeground #CCCCCC
settings.textInputBackground #262626
settings.textInputBorder #262626
settings.textInputForeground #CCCCCC
sideBar.background #1e1e1e
sideBar.border #262626
sideBar.dropBackground #53595d80
sideBar.foreground #CCCCCC
sideBarSectionHeader.background #80808033
sideBarSectionHeader.foreground #CCCCCC
sideBarTitle.foreground #CCCCCC
statusBar.background #1e1e1e
statusBar.border #262626
statusBar.debuggingBackground #CC0000
statusBar.debuggingBorder #262626
statusBar.debuggingForeground #CCCCCC
statusBar.foreground #CCCCCC
statusBar.noFolderBackground #1e1e1e
statusBar.noFolderBorder #262626
statusBar.noFolderForeground #CCCCCC
statusBarItem.activeBackground #ffffff2e
statusBarItem.hoverBackground #ffffff1f
statusBarItem.prominentBackground #00000080
statusBarItem.prominentForeground #CCCCCC
statusBarItem.prominentHoverBackground #0000004d
statusBarItem.remoteBackground #CC0000
statusBarItem.remoteForeground #CCCCCC
symbolIcon.arrayForeground #cccccc
symbolIcon.booleanForeground #cccccc
symbolIcon.classForeground #ee9d28
symbolIcon.colorForeground #cccccc
symbolIcon.constantForeground #cccccc
symbolIcon.constructorForeground #b180d7
symbolIcon.enumeratorForeground #ee9d28
symbolIcon.enumeratorMemberForeground #75beff
symbolIcon.eventForeground #ee9d28
symbolIcon.fieldForeground #75beff
symbolIcon.fileForeground #cccccc
symbolIcon.folderForeground #cccccc
symbolIcon.functionForeground #b180d7
symbolIcon.interfaceForeground #75beff
symbolIcon.keyForeground #cccccc
symbolIcon.keywordForeground #cccccc
symbolIcon.methodForeground #b180d7
symbolIcon.moduleForeground #cccccc
symbolIcon.namespaceForeground #cccccc
symbolIcon.nullForeground #cccccc
symbolIcon.numberForeground #cccccc
symbolIcon.objectForeground #cccccc
symbolIcon.operatorForeground #cccccc
symbolIcon.packageForeground #cccccc
symbolIcon.propertyForeground #cccccc
symbolIcon.referenceForeground #cccccc
symbolIcon.snippetForeground #cccccc
symbolIcon.stringForeground #cccccc
symbolIcon.structForeground #cccccc
symbolIcon.textForeground #cccccc
symbolIcon.typeParameterForeground #cccccc
symbolIcon.unitForeground #cccccc
symbolIcon.variableForeground #75beff
tab.activeBackground #262626
tab.activeBorder #CC0000
tab.activeForeground #ffffff
tab.activeModifiedBorder #3399cc
tab.border #262626
tab.hoverBackground #262626
tab.inactiveBackground #1e1e1e
tab.inactiveForeground #ffffff80
tab.inactiveModifiedBorder #3399cc80
tab.lastPinnedBorder #585858
tab.unfocusedActiveBackground #262626
tab.unfocusedActiveBorder #CC000080
tab.unfocusedActiveForeground #ffffff80
tab.unfocusedActiveModifiedBorder #3399cc80
tab.unfocusedHoverBackground #26262680
tab.unfocusedInactiveBackground #1e1e1e
tab.unfocusedInactiveForeground #ffffff40
tab.unfocusedInactiveModifiedBorder #3399cc40
terminal.ansiBlack #000000
terminal.ansiBlue #2472c8
terminal.ansiBrightBlack #666666
terminal.ansiBrightBlue #95b7f7
terminal.ansiBrightCyan #29b8db
terminal.ansiBrightGreen #CC0000
terminal.ansiBrightMagenta #d670d6
terminal.ansiBrightRed #f14c4c
terminal.ansiBrightWhite #e5e5e5
terminal.ansiBrightYellow #f5f543
terminal.ansiCyan #11a8cd
terminal.ansiGreen #CC0000
terminal.ansiMagenta #bc3fbc
terminal.ansiRed #fb5245
terminal.ansiWhite #CCCCCC
terminal.ansiYellow #fac149
terminal.border #262626
terminal.foreground #CCCCCC
terminal.selectionBackground #ffffff40
textBlockQuote.background #7f7f7f1a
textBlockQuote.border #007acc80
textCodeBlock.background #0a0a0a66
textLink.activeForeground #CC0000
textLink.foreground #CCCCCC
textPreformat.foreground #d7ba7d
textSeparator.foreground #ffffff2e
titleBar.activeBackground #1e1e1e
titleBar.activeForeground #CCCCCC
titleBar.border #262626
titleBar.inactiveBackground #1e1e1e
titleBar.inactiveForeground #CCCCCC
tree.indentGuidesStroke #585858
widget.shadow #262626
window.activeBorder #262626 keyword.control, constant.other.color, punctuation, meta.tag, punctuation.definition.tag, punctuation.separator.inheritance.php, punctuation.definition.tag.html, punctuation.definition.tag.begin.html, punctuation.definition.tag.end.html, punctuation.section.embedded, keyword.other.template, keyword.other.substitution #89DDFF —
entity.name.tag, meta.tag.sgml, markup.deleted.git_gutter #f07178 —
entity.name.function, meta.function-call, variable.function, support.function, keyword.other.special-method #82AAFF —
meta.block variable.other #f07178 —
support.other.variable, string.other.link #f07178 —
constant.numeric, constant.language, support.constant, constant.character, constant.escape, variable.parameter, keyword.other.unit, keyword.other #F78C6C —
string, constant.other.symbol, constant.other.key, entity.other.inherited-class, markup.heading, markup.inserted.git_gutter, meta.group.braces.curly constant.other.object.key.js string.unquoted.label.js #C3E88D —
entity.name, support.type, support.class, support.other.namespace.use.php, meta.use.php, support.other.namespace.php, markup.changed.git_gutter, support.type.sys-types #FFCB6B —
source.css support.type.property-name, source.sass support.type.property-name, source.scss support.type.property-name, source.less support.type.property-name, source.stylus support.type.property-name, source.postcss support.type.property-name #B2CCD6 —
entity.name.module.js, variable.import.parameter.js, variable.other.class.js #FF5370 —
variable.language #FF5370 italic
entity.name.method.js #82AAFF italic
meta.class-method.js entity.name.function.js, variable.function.constructor #82AAFF —
entity.other.attribute-name #C792EA —
text.html.basic entity.other.attribute-name.html, text.html.basic entity.other.attribute-name #FFCB6B italic
entity.other.attribute-name.class #FFCB6B —
source.sass keyword.control #82AAFF —
constant.character.escape #89DDFF —
*url*, *link*, *uri* — underline
tag.decorator.js entity.name.tag.js, tag.decorator.js punctuation.definition.tag.js #82AAFF italic
source.js constant.other.object.key.js string.unquoted.label.js #FF5370 italic
source.json meta.structure.dictionary.json support.type.property-name.json #C792EA —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #FFCB6B —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #F78C6C —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #FF5370 —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #C17E70 —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #82AAFF —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #f07178 —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #C792EA —
source.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json meta.structure.dictionary.value.json meta.structure.dictionary.json support.type.property-name.json #C3E88D —
text.html.markdown, punctuation.definition.list_item.markdown #EEFFFF —
text.html.markdown markup.inline.raw.markdown #C792EA —
text.html.markdown markup.inline.raw.markdown punctuation.definition.raw.markdown #65737E —
markdown.heading, markup.heading | markup.heading entity.name, markup.heading.markdown punctuation.definition.heading.markdown #C3E88D —
markup.italic #f07178 italic
markup.bold, markup.bold string #f07178 bold
markup.bold markup.italic, markup.italic markup.bold, markup.quote markup.bold, markup.bold markup.italic string, markup.italic markup.bold string, markup.quote markup.bold string #f07178 bold
markup.underline #F78C6C underline
markup.quote punctuation.definition.blockquote.markdown #65737E —
string.other.link.title.markdown #82AAFF —
string.other.link.description.title.markdown #C792EA —
constant.other.reference.link.markdown #FFCB6B —
markup.raw.block.fenced.markdown #00000050 —
punctuation.definition.fenced.markdown #00000050 —
markup.raw.block.fenced.markdown, variable.language.fenced.markdown, punctuation.section.class.end #EEFFFF —
variable.language.fenced.markdown #65737E —
meta.separator #65737E bold
export interface User {
id : string ;
name : string ;
role : " admin " | " member " ;
tags : string [] ;
}
/**
* Fetch user data by ID
* @ param id
* @ returns User object or null if ID is invalid
*/
export async function fetchUser ( id : string ) : Promise < User | null > {
if ( ! id ) {
return null ;
}
const response = await fetch ( ` /api/users/ ${ id }` , {
method : " GET " ,
headers : { Accept : " application/json " },
} ) ;
if ( ! response . ok ) {
throw new Error ( ` HTTP ${ response . status }` ) ;
}
return ( await response . json ()) as User ;
}
function greet ( user : User ) : string {
// Simple greeting function that uses the user's name
return ` Hello, ${ user . name } ! ` ;
}
fetchUser.ts
index.ts
README.md
src
components
fetchUser.ts
src
components
fetchUser.ts
fetchUser 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Problems1
Output
Debug Console
Terminal
Ports
~/my-project $ pnpm dev
▲ Next.js ready on http://localhost:3000
✓ compiled client and server successfully in 412ms
wait - compiling /theme/vscode...
~/my-project
main*
XSTheme | Coding Theme Button.tsx
31
$
export interface User {
id : string ;
name : string ;
role : " admin " | " member " ;
tags : string [] ;
}
/**
* Fetch user data by ID
* @ param id
* @ returns User object or null if ID is invalid
*/
export async function fetchUser ( id : string ) : Promise < User | null > {
if ( ! id ) {
return null ;
}
const response = await fetch ( ` /api/users/ ${ id }` , {
method : " GET " ,
headers : { Accept : " application/json " },
} ) ;
if ( ! response . ok ) {
throw new Error ( ` HTTP ${ response . status }` ) ;
}
return ( await response . json ()) as User ;
}
function greet ( user : User ) : string {
// Simple greeting function that uses the user's name
return ` Hello, ${ user . name } ! ` ;
}