backend.ts 329 B

12345678910111213
  1. import { postJSON } from '@/infrastructure/fetch-json'
  2. import { Word } from './spellchecker'
  3. export async function learnWordRequest(word?: Word) {
  4. if (!word || !word.text) {
  5. throw new Error(`Invalid word supplied: ${word}`)
  6. }
  7. return await postJSON('/spelling/learn', {
  8. body: {
  9. word: word.text,
  10. },
  11. })
  12. }