Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

loopbackjs - Rest connector with Loopback 3.x (loopback-connector-rest)

I'm new with loopback (I'm using 3.27 version). I'm trying to call an endpoint REST that gives me a json.

I created a Datasource:

{
  "connector": "rest",
  "debug": false,
  "options": {
    "headers": {
      "accept": "application/json",
      "content-type": "application/json"
    },
    "strictSSL": false
  },
  "operations": [
    {
      "template": {
        "method": "GET",
        "url": "http://foobar.com,
        "options": {
          "strictSSL": false,
          "useQuerystring": false
        },
        "responsePath": "$.results"
      },
      "functions": {
        “getFooBar: []
      }
    }
  ]
}

Then in a boot script, I would invoke the endpoint that I defined in the datasource (foobar) programmatically, because it has to be called from a crontab.

  • How can I invoke the GET operation?
  • I have to create a function in the boot script named getFooBar()?
  • How can I get the JSON returned by the endpoint?

Thank you

question from:https://stackoverflow.com/questions/65905247/rest-connector-with-loopback-3-x-loopback-connector-rest

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...