Skip to content

Instantly share code, notes, and snippets.

@Lyokolux
Last active September 23, 2022 11:48
Show Gist options
  • Save Lyokolux/defa22aa20210b814b487fe1a9702586 to your computer and use it in GitHub Desktop.
Save Lyokolux/defa22aa20210b814b487fe1a9702586 to your computer and use it in GitHub Desktop.
Masterarbeit - PoC for Mattermost in a nuxt environment.
import { mattermostClient, channel_id } from '~/server/lib/mattermost'
const message = {
channel_id,
message: 'Send from Nitro!',
}
// SUCCESSFUL:
// curl -i -X POST -H 'Authorization: Bearer $MATTERMOST_API_TOKEN' https://<DOMAIN>/api/v4/posts -d '{"message": "Test Nachricht", "channel_id":"$MATTERMOST_API_CHANNEL_ID"}'
export default async () => {
const response = await mattermostClient.createPost(message)
return {
response,
}
}
import { Client4 } from "@mattermost/client"
import { endpoint, token } from "./_credentials"
const mattermostClient = new Client4()
mattermostClient.setUrl(endpoint)
mattermostClient.setToken(token)
export {
mattermostClient
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment