{"id":23379400,"url":"https://github.com/log-oscon/redux-wpapi","last_synced_at":"2025-04-10T20:46:22.764Z","repository":{"id":57351902,"uuid":"67241693","full_name":"log-oscon/redux-wpapi","owner":"log-oscon","description":"WP API integration for a Redux based Application","archived":false,"fork":false,"pushed_at":"2017-09-06T10:34:20.000Z","size":122,"stargazers_count":22,"open_issues_count":6,"forks_count":4,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-24T18:21:13.866Z","etag":null,"topics":["node-wpapi","redux","wordpress"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/log-oscon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-02T17:23:00.000Z","updated_at":"2023-08-24T15:02:00.000Z","dependencies_parsed_at":"2022-08-29T11:00:28.710Z","dependency_job_id":null,"html_url":"https://github.com/log-oscon/redux-wpapi","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log-oscon%2Fredux-wpapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log-oscon%2Fredux-wpapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log-oscon%2Fredux-wpapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/log-oscon%2Fredux-wpapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/log-oscon","download_url":"https://codeload.github.com/log-oscon/redux-wpapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208603,"owners_count":21065203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["node-wpapi","redux","wordpress"],"created_at":"2024-12-21T19:18:30.310Z","updated_at":"2025-04-10T20:46:22.741Z","avatar_url":"https://github.com/log-oscon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redux-wpapi\n[![npm version](https://img.shields.io/npm/v/redux-wpapi.svg?style=flat-square)](https://www.npmjs.com/package/redux-wpapi)\n[![Build Status](https://travis-ci.org/log-oscon/redux-wpapi.svg?branch=master)](https://travis-ci.org/log-oscon/redux-wpapi)\n\nA [node-wpapi](https://github.com/WP-API/node-wpapi) integration for a Redux based Application.\n\n## How it Works\nThis library exposes [node-wpapi](https://github.com/WP-API/node-wpapi) instance through the actionCreator [callAPI](#/src/actions/callAPI.js). The resulting\naction is interpreted in [the middleware](#the-middleware), doing so by resolving the request and controlling the reducer through actions.\n\n## Installation\n```sh\nnpm install --save redux-wpapi\n```\nThen, to enable ReduxWPAPI, use [`applyMiddleware()`](http://redux.js.org/docs/api/applyMiddleware.html) and [`combineReducers()`](http://redux.js.org/docs/api/combineReducers.html):\n\n```js\nimport reducers from './reducers';\nimport ReduxWPAPI from 'redux-wpapi';\n\nconst { reducer: wp, middleware } = new ReduxWPAPI({ /* … */ });\nconst store = createStore(\n  // the reducer must be placed at the root of the state as `wp`\n  // so the selector knows where state lives in\n  { ...reducers, wp },\n  applyMiddleware(middleware)\n);\n\n```\n\n## Usage\n```js\nimport React from 'react';\nimport { wp, selectRequest, ResponseStatus } from 'redux-wpapi';\nimport { connect } from 'react-redux';\n\nexport class HomePage extends React.Component {\n  static loadData(props) {\n    return props.callAPI(\n      // The name where the request state will be placed\n      'HomePagePosts',\n      // A callback where wpapi instance is injected\n      api =\u003e\n      api.posts()\n      .page(props.page)\n      .perPage(props.perPage)\n    );\n  }\n\n  componentWillMount() {\n    HomePage.loadData(this.props);\n  }\n\n  componentWillReceiveProps(props) {\n    HomePage.loadData(props);\n  }\n\n  render() {\n    const { status, data: posts } = this.props.request;\n\n    if (!posts) {\n      switch (status) {\n          case ResponseStatus.pending: return \u003cdiv\u003eLoading…\u003c/div\u003e;\n          case ResponseStatus.rejected: return \u003cdiv\u003eAn error has occurred\u003c/div\u003e;\n      }\n    }\n\n    return (\n      \u003cdiv\u003e\n        {!posts.length ? \u003cNoPostFound /\u003e : \u003cPostList posts={posts} /\u003e}\n      \u003c/div\u003e\n    );\n  }\n}\n\nexport default connect(createStructuredSelector({\n  request: selectRequest('HomePagePosts'),\n}), { callAPI })(HomePage);\n```\n\n## Contributions\n\nAll contributions are welcome, and very much appreciated.\n\nWe are preparing some helper [documents](https://github.com/log-oscon/redux-wpapi/issues/4) to facilitate the process (hopefully), but for now we're following the these guidelines:\n\n* Be reasonable\n* Give as much detailed information as you can\n* Keep it as short as possible\n* Let the code talk\n\n### Must have's\n\nEvery Pull Request must have the following:\n\n* Unit tests for any functionality that's exposed to the end user.\n* An entry in the [CHANGELOG.md](https://github.com/log-oscon/redux-wpapi/master/CHANGELOG.md) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flog-oscon%2Fredux-wpapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flog-oscon%2Fredux-wpapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flog-oscon%2Fredux-wpapi/lists"}