1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

enebularでnode-red その17

Last updated at Posted at 2024-10-08

概要

enebularでnode-redやってみる。
練習問題やってみた。

練習問題

webapiを作れ。

方針

  • クラウド実行環境使う。
  • datastore使う。
  • エンドポイントにGETなら、一覧をjsonで返す。
  • エンドポイントにPOSTなら、保存して、jsonで返す。
  • jsonは、timestamp,name,commentで出来てる。
  • datastoreは、メインキーにtimestamp。

クラウド実行環境

データストアへの接続
データストアへの接続を行う場合は"ON"にしてください。

datastore

image.png

フロー

  • switchでPOST、GETを分岐する
  • GETなら、データ検索して、一覧をJSONで返す。
  • POSTなら、データ保存して、JSONで返す。
  • timestampは、投入するデータを整える。
  • json headersで、Content-Typeをjsonにする。

image.png

接続テスト

curl -i https://lcdp003.enebular.com/****/

json

[
{"timestamp":"1728082796491"},
{"timestamp":"1728083796491","name":"ai","publish":"ture","condition":"good","comment":"ok"},
{"timestamp":"1728083845078","name":"aita","publish":"1","condition":"good","comment":"ok"},
{"timestamp":"1728082865943"},
{"timestamp":"1728360810390","name":"test","comment":"iine"},
{"timestamp":"1728082597520"},{"timestamp":"1728082516509"},
{"timestamp":"1728082616074"}
]

以上

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?