Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roziscoding/grammy-vue
https://github.com/roziscoding/grammy-vue
Last synced: about 18 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/roziscoding/grammy-vue
- Owner: roziscoding
- Created: 2023-02-27T22:21:05.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-27T22:28:59.000Z (almost 2 years ago)
- Last Synced: 2025-01-06T02:12:05.637Z (6 days ago)
- Language: TypeScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
grammy-vue
---Simple utility hook to call the Telegram API using [grammy](https://grammy.dev) and track the request status with Vue.js refs
## Usage
```html
import { ref } from 'vue';
import { useTelegramApi } from 'grammy-vue';const token = ref('')
const { useApiMethod } = useTelegramApi(token)
const { refresh: getMe, state, data: botInfo, error } = useApiMethod('getMe')
GetMe
Type the token and click the button
Loading bot info...
Grammy error: {{ error.message }}
Loaded info for bot {{ botInfo.username }}```
### Resetting status after a set amount of time
The `useApiMethod` hook takes an optional second parameter, which is the number of milliseconds to wait before setting the state back to `idle`. If you don't specify this parameter, the state will not be automatically reset.
```html
import { ref } from 'vue';
import { useTelegramApi } from 'grammy-vue';const token = ref('')
const url = ref('')
const { useApiMethod } = useTelegramApi(token)
const { refresh: setWebhook, state, error } = useApiMethod('setWebhook', 1000) // state will be reset after 1 second
SetWebhook
Type the token and the url, then click the button
Setting webhook...
Grammy error: {{ error.message }}
Webhook was set!```