0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

kintone.proxy()をブラウザのコンソールから叩くためのスニペット

Last updated at Posted at 2023-05-08

kintone.proxy()

レスポンスがJSONなら、こんな感じ。

await kintone
  .proxy(
    'https://example.com',
    'POST',
    {
      'Content-Type': 'application/json',
      'x-api-key': 'xxxxxx',
    },
    {
      data1: 'foo',
      data2: 'bar',
    }
  )
  .then(([body, status, header]) => ({
    body: JSON.parse(body),
    status,
    header,
  }));

APIが200以外を返すときもthen()の方に入るので、サクッと試すだけならcatch()は不要だと思います。

公式ドキュメントはこちら

外部の API を実行する
https://cybozu.dev/ja/kintone/docs/js-api/proxy/kintone-proxy/

kintone.plugin.app.proxy()

第一引数にプラグインIDが入る以外は一緒です。

await kintone.plugin.app
  .proxy(
    '(plugin-id)',
    'https://example.com',
    'POST',
    {
      'Content-Type': 'application/json',
      'x-api-key': 'xxxxxx',
    },
    {
      data1: 'foo',
      data2: 'bar',
    }
  )
  .then(([body, status, header]) => ({
    body: JSON.parse(body),
    status,
    header,
  }))

公式ドキュメントはこちら

外部の API を実行する
https://cybozu.dev/ja/kintone/docs/js-api/plugins/kintone-plug-in-proxy/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?