Code Lab: How to Work with Result Types

Below you can find different versions of this Code Lab. You can copy the corresponding git clone command and clone the version you want. To copy the command use the copy icon to the right.

Alternatively, you can clone the whole repository or update it with git fetch --all and checkout a specific tag, e.g. with git checkout tags/1.0.1.

1.0.0
Latest
Main Packages
  • @dfinity/agent 1.0.1
  • @dfinity/candid 1.0.1
  • @dfinity/principal 1.0.1
  • svelte 4.2.12
  • sveltejs/kit 2.5.4
Project Type
  • Two canisters (frontend and backend)
Backend Canister
  • Motoko
  • Contains a small dictionary database
  • Contains the public functions addWord and getWord
  • Focuses on the use of the Result type
Frontend
  • SvelteKit
  • Shows the use of a Result type in JavaScript
Highlight img
Exercise

Feel free to add the frontend application part for the addWord function and also an error (#err) Result type, if a new entry cannot be stored successfully in the data store by your own as an exceriece.