# react-native-api-context

> An react native context to manage all api calls in one place

Latest version **1.2.2** (published 2023-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-api-context
pnpm add react-native-api-context
yarn add react-native-api-context
bun add react-native-api-context
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2023-02-20 |
| First published | 2022-11-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 65.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mostafa Mahmoud |
| Maintainers | mostafamahmoudabdelaleem |
| Keywords | react-native, ios, android, axios, API, POST, GET |

## Links

- npm: https://www.npmjs.com/package/react-native-api-context
- Repository: https://github.com/mostafamahmoudabdelaleem/react-native-api-context
- Homepage: https://github.com/mostafamahmoudabdelaleem/react-native-api-context#readme
- Issues: https://github.com/mostafamahmoudabdelaleem/react-native-api-context/issues
- npm.io page: https://npm.io/package/react-native-api-context

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^1.1.3
- [moment](https://npm.io/package/moment.md) ^2.29.4

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2023-02-20
- 1.2.1 — 2023-02-20
- 1.2.0 — 2022-12-14
- 1.0.1 — 2022-11-09
- 1.0.0 — 2022-11-09
- 0.1.0 — 2022-11-09

## README

# react-native-api-context

An react native context to manage all api calls in one place

## Installation

```sh
npm install react-native-api-context

yarn add react-native-api-context
```

## Usage

```js
// inside root App.tsx
import { APIContextProvider } from 'react-native-api-context';
import Page from './Page';

export default function App() {
	const BASE_URL = 'https://jsonplaceholder.typicode.com'

	return (
		<APIContextProvider BaseURL={BASE_URL}>
			<Page/>
		</APIContextProvider>
	);
}
```

```js
// inside any child component of APIContextProvider
import { APIContext } from 'react-native-api-context';

export default function Page() {
    const { Get } = React.useContext(APIContext)

    useEffect(() => {
        Get({
            path: 'posts'
        })
            .then(resp => {
                console.log('[APIContext resp]:', resp)
            })
            .catch(err => {
                console.log('[APIContext error]:', err)
            })
    }, []);

    return (
        ...
    );
}
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---

Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)

---
_Source: https://npm.io/package/react-native-api-context · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
