@base-cms/base4-rest-api
Advanced tools
Comparing version 1.0.0 to 1.1.0
{ | ||
"name": "@base-cms/base4-rest-api", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A Base4 REST API client.", | ||
@@ -23,3 +23,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "84a09c3f2d6687951b19cabd448c30797bc24fb9" | ||
"gitHead": "004792ffaa2ab317dffbea61ee1267ac8b5c1533" | ||
} |
@@ -123,2 +123,12 @@ const fetch = require('node-fetch'); | ||
async uploadImageFromUrl({ url } = {}) { | ||
if (!url) throw new Error('An image URL must be passed to upload.'); | ||
return this.fetch({ | ||
method: 'post', | ||
type: 'custom', | ||
body: { uri: url }, | ||
endpoint: 'upload-embedded', | ||
}); | ||
} | ||
async fetch({ | ||
@@ -165,4 +175,5 @@ method, | ||
buildUrl({ type, endpoint } = {}) { | ||
if (!['persistence', 'search'].includes(type)) throw new Error(`The API resource type '${type}' is not supported.`); | ||
if (!['persistence', 'search', 'custom'].includes(type)) throw new Error(`The API resource type '${type}' is not supported.`); | ||
if (!endpoint) throw new Error('An API endpoint is required.'); | ||
if (type === 'custom') return `${this.uri}/${cleanPath(endpoint)}`; | ||
return `${this.uri}/${cleanPath(this.baseEndpoint)}/${type}/${cleanPath(endpoint)}`; | ||
@@ -169,0 +180,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8797
212