This is an example project demonstrating the usage of the HackMD API client.
- First, build the HackMD API package:
cd ../../nodejs
npm install
npm run build
cd ../examples/nodejs- Install the example dependencies:
npm install-
Set up your HackMD access token using one of these methods:
a. Set it as an environment variable:
# For Unix/Linux/macOS export HACKMD_ACCESS_TOKEN=your_access_token_here # For Windows PowerShell $env:HACKMD_ACCESS_TOKEN="your_access_token_here"
b. Or create a
.envfile in the project root (not tracked by git):HACKMD_ACCESS_TOKEN=your_access_token_here
You can get your access token from HackMD API documentation.
To run the example:
npm startThe example demonstrates several features of the HackMD API client:
- Getting user information
- Creating a new note
- Using ETag support for caching
- Updating note content
- Getting raw response data
- Deleting notes
- Retry configuration with exponential backoff
- ETag support for caching
- Response data unwrapping
- Error handling
- Environment variable configuration