Coder Social home page Coder Social logo

Links to state about redux-json-api HOT 5 CLOSED

DimaelVertigo avatar DimaelVertigo commented on June 3, 2024
Links to state

from redux-json-api.

Comments (5)

egeriis avatar egeriis commented on June 3, 2024 1

Yeah, so only data and included will be handled by redux-json-api, as outlined above.

componentDidMount() {
  const response = await this.props.dispatch(readEndpoint('/domains?include=remote_access'));
  console.log(response);
}

Try this, you can see that you get an ApiResponse class instance. From here you can read meta and links.

fwiw I'm working on an additional library that will make this a bit easier, but it's out of scope for redux-json-api: https://github.com/redux-json-api/react-redux-json-api

from redux-json-api.

egeriis avatar egeriis commented on June 3, 2024 1

Yes, exactly. await is just another way to wait for the promise to resolve 🙂

from redux-json-api.

egeriis avatar egeriis commented on June 3, 2024

You mean the root links and meta properties? They're not automatically populated to redux state, no. The reason is that redux-json-api takes care of storing resources independent of requests, and root.links, root.meta are request-specific.

You can easily take care of storing them in whatever way you need, while keeping the benefit of having redux-json-api store your resources:

const tasksResponse = await readEndpoint('/data/tasks');
const responseLinks = tasksResponse.links;
const responseMeta = tasksResponse.meta;

from redux-json-api.

DimaelVertigo avatar DimaelVertigo commented on June 3, 2024

Yes, I mean the root links and meta properties.
image

I try to include root.links and root.meta to state and to props later.

componentDidMount() {
    this.props.dispatch(readEndpoint('/domains?include=remote_access'));
  }

I will use this data for pagination.

from redux-json-api.

DimaelVertigo avatar DimaelVertigo commented on June 3, 2024
  componentDidMount() {
    this.props.dispatch(readEndpoint('/domains?include=remote_access'))
      .then(r => {
        console.log(r.body.links);
        console.log(r.body.meta)
      });
  }

I got access to links and meta. Thank you!

from redux-json-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.