Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

mwp-api-state

Package Overview
Dependencies
Maintainers
1
Versions
1565
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mwp-api-state

Redux helpers to manage API data in a MWP app

latest
Source
npmnpm
Version
27.0.28
Version published
Weekly downloads
34
-29.17%
Maintainers
1
Weekly downloads
 
Created
Source

API state

Redux state management for Meetup REST API data

Middleware/Epics

The API middleware provides core functionality for interacting with API data - managing authenticated user sessions, syncing with the current URL location, caching data, and POSTing data to the API.

Sync /sync.js

This epic is currently only responsible for fetching the data from the API server on initial render or client-side user navigation.

on SERVER_RENDER or LOCATION_CHANGE, which provide a location (URL):

  • Match location to defined routes and extract the renderProps like URL path and querystring params
  • Check routes for query functions that return data needs, and process them into an array
  • Trigger API_REQ containing the queries

on API_REQ, which provides queries:

  • Send the queries to the application server, which will make the corresponding external API calls.
  • When the application server returns data, trigger API_RESP_SUCCESS action containing API response array and query array
  • If the application server responds with an error, trigger API_RESP_ERROR

Cache /cache.js

See the Caching docs

Disable cache

By design, the cache masks slow responses from the API and can create a 'flash' of stale content before the API responds with the latest data. In development, this behavior is not always desirable so you can disable the cache by adding a __nocache param to the query string. The cache will remain disabled until the the page is refreshed/reloaded without the param in the querystring.

http://localhost:8000/ny-tech/?__nocache

Reducer

The api export of the api-state module is a reducer that will return data from the API using Queries.

Action creators

To send/receive data to/from the REST API, use get, post, patch, put and del action creators from api-state.

See the Queries documentation for more details on usage.

FAQs

Package last updated on 19 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts