spring-attic / tut-react-and-spring-data-rest

React.js and Spring Data REST :: A tutorial based on the 5-part blog series by Greg Turnquist
https://spring.io/guides/tutorials/react-and-spring-data-rest
883 stars 1.58k forks source link

Part 2 - Hypermedia Controls - Paging from frontend react not working #126

Closed marcelovidigal closed 4 years ago

marcelovidigal commented 4 years ago

I am running same code from GIT but paging not working, no pagination is shown, JS code does not present errors, but at each execution all items are displayed. Does anyone have any suggestions for this, I believe it is something with the rest client.

marcelovidigal commented 4 years ago

Problem solved with the inclusion of the template interceptor in client.js. Remember to replace all done with then in app.js.

const template = require('rest/interceptor/template'); ... .wrap(template) .wrap(defaultRequest, { headers: { 'Accept': 'application/hal+json' }});

'use strict';

const rest = require('rest');
const defaultRequest = require('rest/interceptor/defaultRequest');
const mime = require('rest/interceptor/mime');
const uriTemplateInterceptor = require('./api/uriTemplateInterceptor');
const errorCode = require('rest/interceptor/errorCode');
const baseRegistry = require('rest/mime/registry');
const template = require('rest/interceptor/template');

const registry = baseRegistry.child();

registry.register('text/uri-list', require('./api/uriListConverter'));
registry.register('application/hal+json', require('rest/mime/type/application/hal'));

module.exports = rest
    .wrap(mime, { registry: registry })
    .wrap(uriTemplateInterceptor)
    .wrap(errorCode)
    .wrap(template)
    .wrap(defaultRequest, { headers: { 'Accept': 'application/hal+json' }});
didy-3 commented 2 years ago

I have the same problem and your solution didnt work for me :(

imbrandonkinard commented 5 months ago

For what it is worth, this worked for me after completing part 5 but losing front-end paging options.