Dashboard-Plugin
Docs HomeDashboard plugins and appsInfomakerNaviga global
  • About
  • Intro
  • Getting started
  • The anatomy of a plugin
  • Manifest structure
  • Getting started
    • Get Dashboard-Plugin
    • Build
  • What's new
  • Components
    • Agent
      • Actions
    • Application
    • Widget
    • Health
    • Modal
    • Settings
  • API and GUI
    • API
      • Overview
      • register
        • Reducers
        • Portals
        • Requirements
        • Permissions
        • Default config
        • Config Modifiers
      • cache
      • store
      • encrypt
      • decrypt
      • createUUID
      • getLanguage
      • getTextDirection
      • getTimeFormat
      • getKeyCharFromCode
      • getKeyCodeFromChar
      • event
      • Logger
      • buildRouteUrlWithDispatchableEvent
      • getUser
      • getAction
      • getPortal
      • getConfig
      • getLocalize
      • getAvailableActions
      • getAvailablePortals
      • request
      • setHealth
      • openModal
      • closeModal
      • confirm
      • notifications
      • hasPermission
      • standalone
      • withUser
      • useModal
      • useSheet
      • useUser
      • useConfig
      • useLocalize
      • useApplication
      • useMappings
      • useStandalone
    • GUI
      • Core GUI
      • Style-Guide
    • Modules
      • GUI
      • Utility
      • NavigaID
        • getUserToken
        • getApplicationToken
        • getGroupsFromToken
  • Mappings
  • Plugins deployments
  • S3 upload
  • Deprecations
    • 4.1.0
    • 4.0.0
    • 2.1.0
Powered by GitBook
On this page

Was this helpful?

  1. API and GUI
  2. API

request

request is a proxy request to come around CORS issues.

Both callbacks and promises is supported so it is all about which approach you will want to take.

How to use

(as callback)

import { Plugin } from'@root'

Plugin.request('YOUR_ENDPOINT', data => console.log(data))

params (as callback)

import { Plugin } from'@root'

Plugin.request('YOUR_ENDPOINT', {
    json: true
}, response => console.log(response))

// OR url in params
Plugin.request({
    url: 'YOUR_ENDPOINT',
    json: true
}, response => console.log(response))

When working with callbacks the request component will always try to parse the response as json.

If you want to handle the parsing by yourself and parse as something else than json promise is more suitable.

(as promise)

import { Plugin } from'@root'

Plugin.request('YOUR_ENDPOINT')
    .then(response => response.text())
    .then(response => console.log(response))

GET is the default request method.

Advanced examples

Pluginrequest({
    url: 'YOUR_ENDPOINT',
    method: 'POST',
    formData {
        foo: 'bar'
    }
}, response => console.log(response))

// ============= //

Plugin.request({
    url: 'YOUR_ENDPOINT',
    headers: {
        "x-request-params": 'foobar'
    }
}, response => console.log(response))
PreviousgetAvailablePortalsNextsetHealth

Last updated 4 years ago

Was this helpful?