The LoopBack REST Connector (v6.0.7) enables LoopBack applications to interact with third-party REST APIs using a template-driven approach. It supports both resource operations and custom methods defined via templates. Current stable version is 6.0.7, supporting Node.js >=20. Key differentiators include integration with LoopBack 4's service and controller layers, template-based API mapping, and response path extraction. Compared to generic HTTP clients, it provides declarative datasource configuration and automatic CRUD mapping for REST endpoints.
npm install loopback-connector-restNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures a LoopBack REST datasource with a Google Geocoding template and calls the geocode function. Demonstrates datasource setup, template definition with response path extraction, and async invocation.
Upgrade to Node.js >=20 and migrate to LoopBack 4 service/repository pattern.
Consider using REST connector with 'axios' or native fetch by overriding the request module, or migrate to loopback-connector-openapi.
Use `import { RestConnector } from 'loopback-connector-rest';` instead of default import.Always prefix JSONPath expressions with '$.' (e.g., '$.results[0]' not 'results[0]').
Use custom template operations or migrate to LoopBack 4 service layer with REST datasource proxying.
Log the raw response (set debug: true) and adjust the responsePath to match the actual JSON structure.
Verify the URL is correct and accessible from the Node.js environment. Check network proxy settings if behind a corporate firewall.
Set 'strictSSL': false in the datasource options or operation template options, but only for development/trusted APIs.
Ensure template.method is one of 'GET', 'POST', 'PUT', 'DELETE', 'PATCH' (uppercase). Example: "method": "GET"