Secret data stored with Storage API is "undefined" when retrieving it again

I feel like I may be misunderstanding how the Storage API works. I am trying to use that API to store an API access token, showing a text field only if an access token is not yet stored. But when I try to retrieve that token from Storage, it’s always undefined.

import ForgeUI, { useProductContext, useState, render, Fragment, Form, Text, Link, TextField, IssuePanel } from '@forge/ui';
import { storage } from '@forge/api';

const App = () => {
  const context = useProductContext()
  const jiraAccountId = context.accountId
  const tokenKey = `${jiraAccountId}-harvest-token-key`
  const [harvestToken, setHarvestToken] = useState(async () => await storage.get(tokenKey))

  const onSubmit = async (formData) => {
    // console.log(JSON.stringify(formData))
    await storage.setSecret(tokenKey, formData.token)
    setHarvestToken(formData.token)
  }

  console.log('outside ' + harvestToken)

  let uiComponents = new Array()

  if (harvestToken == undefined) {
    uiComponents.push(
      <Fragment>
        <Text>To use this Harvest plugin, you need to enter your personal Harvest access token, which you can create <Link href="https://id.getharvest.com/developers">here</Link>. </Text>
        <Form onSubmit={onSubmit}>
          <TextField isRequired="true" autoComplete="off" type="text" label="Harvest Access Token" name="token" />
        </Form>
      </Fragment>
    )
  } else {
    uiComponents.push(
      <Fragment>
        <Text>{harvestToken}</Text>
      </Fragment>
    )
  }

  return (
    <Fragment>
      {uiComponents}
    </Fragment>
  );
};

export const run = render(
  <IssuePanel>
    <App />
  </IssuePanel>
);

Hey :wave:,
from a quick glance at your code, shouldn’t you use storage.getSecret instead of storage.get?

That was exactly it. I realized this yesterday and wanted to remove this post again, but it was flagged as spam and not accessible. Thanks for the help regardless!