ketting | The HATEOAS client for javascript | REST library
kandi X-RAY | ketting Summary
kandi X-RAY | ketting Summary
The Ketting library is a generic REST client with Hypermedia features.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ketting
ketting Key Features
ketting Examples and Code Snippets
Community Discussions
Trending Discussions on ketting
QUESTION
I'm using ketting for my React REST client. The library provides hooks to access some data, In my case, this is this hook :
...ANSWER
Answered 2021-Mar-21 at 07:40Using 1 component per Resource is exactly the pattern that's recommended. I'd even say it's a best practice. Note that a call to useResource
will not result in an API call if there was a cached resource state.
If you find that you are seeing 1 request per iteration, you might want to make sure that your collection returns every member as an embedded resource. If you use the useCollection
hook, the request will include a Prefer: transclude=item
header to give a hint to the server that embedding might be desired.
Also, react-ketting will do cleanups on unmount.
QUESTION
I'm actually trying the power of react-ketting with a fastify's API.
From the hook useResource, I can get a submit function that will make a POST but I can't know when that submit is done and I can't get the API reply of this POST.
React doesn't allow this? Did I miss a param or must I use something else for PUT/POST like axios in order to have all control ?
...ANSWER
Answered 2021-Apr-12 at 15:53There's two main reasons/processes to do POST requests with Ketting.
- To create a new resource / add a new resource to a collection.
- To do an arbitrary RPC call / submit a form.
When you use the useResource()
hook, and use the submit()
function, the primary purpose of this is to deal with the first case.
Because you are strictly making a new resource, the expectation is that the response contains:
- A
201 Created
status - A
Location
header pointing to the newly created resource.
Optionally, you the server can return the body of the newly created resource, but to do that, the server must also include a Content-Location
header.
If that was your purpose, you can get the result of the POST
request simply by listening to state changes in the component you already have.
If you are in the second category and just want to do an arbitrary POST request and read the response, you should not use the submit()
function returned from the hook.
The submit()
function on the useResource
hook is really used as a 'resource state submissions' mechanism, and it's not good to overload this for other arbitrary POST
requests.
Instead, just use the .post()
function on the Resource
itself.
QUESTION
I using the Angular to request API v.3 in Openproject.org with "ketting" library https://github.com/badgateway/ketting/wiki/Optimizing. But can not switch http/1.1 to http/2 protocol although changed HTTP -> HTTPs for Openproject.
...ANSWER
Answered 2020-Oct-11 at 09:14Amazing! Thank Thorsten Rintelen so much! Your info solved my problem that lasted for about two weeks. I was enabled http/2 for the apache webserver ( according to the guide on the web: https://www.howtoforge.com/how-to-enable-http-2-in-apache/ after enabling https in server-side)
====> This article is solved!
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ketting
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page