umbraco / umbraco.headless.client.nodejs Goto Github PK
View Code? Open in Web Editor NEWNodeJs Client Library and Sample for the Umbraco Headless Cloud Service
Home Page: https://umbraco.com/products/umbraco-heartcore/
License: MIT License
NodeJs Client Library and Sample for the Umbraco Headless Cloud Service
Home Page: https://umbraco.com/products/umbraco-heartcore/
License: MIT License
Hi, I’m trying to use the client library for the current latest angular v8.2.14 with no prevail. Is it supposed to work with angular?
I tried the koa sample app and there it works fine with calling my demo headless account, for an example with this method "client.management.content.root()".
Angular Project: Very basic project from angular setup guide with only 1 route configured for the home page.
The problem which occurs:
GET https://cdn.umbraco.io/content 400
core.js:4002 ERROR Error: Uncaught (in promise): APIRequestError
APIRequestError
at new APIRequestError (APIRequestError.js:19)
at ApiRequest. (ApiRequest.js:122)
at step (ApiRequest.js:33)
at Object.throw (ApiRequest.js:14)
at rejected (ApiRequest.js:6)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
at Object.onInvoke (core.js:26256)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:150)
at zone.js:910
at resolvePromise (zone.js:852)
at resolvePromise (zone.js:809)
at zone.js:913
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:26247)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
at ZoneTask.push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask [as invoke] (zone.js:502)
at invokeTask (zone.js:1693)
Dont know about other projects but in angular it has become a kind of standard to use observables instead of promises.
Is there any plan to support observables instead of promises?
Angular is using rxjs for it, https://rxjs-dev.firebaseapp.com/guide/overview
Hey there,
I've been using the NodeJS client to manage content in my Heartcore Umbraco and I've been struggling with some of the methods; in particular, the create()
method (either from client.management.media
or client.management.content
).
When a FormData is used in create()
(because we are uploading a file with the request) there is only way of doing the request (as far as I've tested it), which is using FileSystem.createReadStream()
. That means that you must have the file you are uploading in the file system.
I was, however, trying to get the file from an url and send it with the request. The media or content node was created, but whenever I opened the node I would get the following error
which was related to this exception
I've tried appending the file in many different ways, to see if I could get it to work, but the only solution I got was to download the file locally and then using the FileSystem to attach it.
The important thing: in this process, I've felt that some documentation was missing on how we "communicate" with Umbraco Heartcore using the client. The several ways (if there are more than one) of uploading a file; the proper way to relate existing media/content nodes, etc.
I am available to improve this issue as I know this can be a little confusing xD
Thanks,
Pedro
It seems this is rarely updated, and the 43 Pull Requests from dependabot that have not been merged kinda puts me off using this. Can this safely be used, or is there a better alternative?
I can't seem to find TypeScript typings for the Node client. Are there any available?
I was hoping for a @types/@umbraco/headless-client
package, but alas - no dice. :)
No offense but guys you don't have any documentation. List of method signatures on the README file are nearly pointless without actual examples or at least method definitions.
When using client.management.media.create
I get the following error:
TypeError: Cannot read property 'data' of undefined at ApiRequest.<anonymous> (/home/lukas/dev/umbraco_migrate/node_modules/@umbraco/headless-client/dist/ApiRequest.js:124:118) at step (/home/lukas/dev/umbraco_migrate/node_modules/@umbraco/headless-client/dist/ApiRequest.js:33:23) at Object.throw (/home/lukas/dev/umbraco_migrate/node_modules/@umbraco/headless-client/dist/ApiRequest.js:14:53) at rejected (/home/lukas/dev/umbraco_migrate/node_modules/@umbraco/headless-client/dist/ApiRequest.js:6:65)
It seems that it comes from this snippet in ApiRequest.ts file, line 84
I tried to investigate what data is supposed to be. It always declared as any.
Due to lack of docs, it is unclear what is expected to be passed into the function. But inspired by this https://our.umbraco.com/documentation/Umbraco-Heartcore/API-Documentation/Content-Management/media/#create-media
I currently create new FormData and try to append content data with a picture. I provide to the function.
EDIT: change to describe the real problem. The original was cause by me by misreading the original error.
Hi Umbraco,
I stumbled upon a possible error when using options with client.delivery.content.children.
It seems to ignore pageSize and page options.
const children = await client.delivery.content.children(pageId, { pageSize: "20", page: "1" });
In the above example pageSize is specified to 20 and should return 15 as there is a total for 15 children. However it only returns 10, even after setting it up in the options.
Video of the error : https://drive.google.com/file/d/1us2l65apApGPj3EFGYQeApGvz2EzoR99/view
Is this an error or am i doing something wrong ?
Would it be possible to change so that the package @umbraco/headless-client dont require dependencies that can cause optimization bailouts?
Hi Devs!
For a new Umbraco Heartcore project we are interested in using this client library to get our development process up-to-speed in no time. Within the entire software architecture & landscape of this project, we make use of Azure API Management to control any & all API's connected to all applications (including the frontend of our new application).
Sadly the various urls used by the Umbraco api (cdn., api. & preview. urls) are hardcoded into this library right now.
Would it be possible to have these URLs be configurable, just like projectAlias, apiKey etc. are configurable in the client?
Kind regards,
Corné Hoskam
iO Digital
Hi,
Having an issue in ie11
'URLSearchParams' is undefined in IE 11
i believe it's to do with the Axios dependancy.
Do you have any workarounds?
Would it be possible to change so that allowSyntheticDefaultImports dont need to be set to true in the tsconfig.json?
Default tsconfig on a angular project:
Error message:
Error: node_modules/@umbraco/headless-client/Clients/Management/ContentManagementClient.d.ts:1:8 - error TS1259: Module '"C:/Test/heartcore/node_modules/@umbraco/headless-client/node_modules/form-data/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
1 import FormData from 'form-data';
~~~~~~~~
node_modules/@umbraco/headless-client/node_modules/form-data/index.d.ts:10:1
10 export = FormData;
~~~~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
Error: node_modules/@umbraco/headless-client/Clients/Management/MediaManagementClient.d.ts:1:8 - error TS1259: Module '"C:/Test/heartcore/node_modules/@umbraco/headless-client/node_modules/form-data/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
1 import FormData from 'form-data';
~~~~~~~~
node_modules/@umbraco/headless-client/node_modules/form-data/index.d.ts:10:1
10 export = FormData;
~~~~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
Error: node_modules/@umbraco/headless-client/Clients/Management/MemberManagementClient.d.ts:1:8 - error TS1259: Module '"C:/Test/heartcore/node_modules/@umbraco/headless-client/node_modules/form-data/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
1 import FormData from 'form-data';
~~~~~~~~
node_modules/@umbraco/headless-client/node_modules/form-data/index.d.ts:10:1
10 export = FormData;
~~~~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
Version
0.8.0
Description
The Client.delivery.content.descendants()
function seems to have the wrong typing in its return type. Typescript infers that it returns the type Promise<Content[] | undefined>
but when invoking the function and debugging its actual output, you seem to get a PagedResponse instead. The return type should then have been inferred as Promise<PagedResponse<Content> | undefined>
resembling that of the children
function.
Reference
Umbraco.Headless.Client.NodeJs/src/Clients/Delivery/ContentDeliveryClient.ts
Lines 124 to 126 in 3c61a2a
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.