https://github.com/scrachstack/fetchnui
NPM Model to send a post request to the backend for NUI Callbacks.
https://github.com/scrachstack/fetchnui
cfx fetchnui fivem module nodejs npm
Last synced: 6 months ago
JSON representation
NPM Model to send a post request to the backend for NUI Callbacks.
- Host: GitHub
- URL: https://github.com/scrachstack/fetchnui
- Owner: ScrachStack
- License: mit
- Created: 2025-02-27T05:28:24.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-04-15T03:08:50.000Z (10 months ago)
- Last Synced: 2025-07-27T07:53:23.381Z (6 months ago)
- Topics: cfx, fetchnui, fivem, module, nodejs, npm
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fetch NUI Module
[](https://discord.gg/tgrU8wgeHx)
## Overview
This module allows you to easily interact with the NUI (Native User Interface) in your frontend applications. With the `Post` function, you can send messages to the NUI with minimal setup.
## Installation
To get started, simply install the module via NPM:
```bash
npm install fetchnui
OR
yarn add fetchnui
```
Import the module
Once installed, you can import the Post function into your frontend JavaScript file:
```js
import Post from 'fetchnui';
```
Usage
Sending Events
Use the Post function to send an event to your NUI interface. The Post function accepts two parameters:
eventName: The name of the event you want to trigger (e.g., 'playerEntered').
data: The data you want to send along with the event (this can be any object).
Example Usage
```js
Post('test', {});
```
In this example, we send an event called 'test' to the NUI with an empty object as the associated data.
Custom Data Example
You can also send custom data with your event:
```js
Post('test', { playerId: 123, playerName: 'JohnDoe' });
```
In this case, we're sending an object with player data to the NUI.
# Example Project Setup
Install the module using NPM/Yarn.
Import the Post function into your project.
Use Post to trigger events and pass data between your frontend and NUI.
```js
import Post from 'fetchnui';
function playerJoined() {
const playerData = { playerId: 123, playerName: 'JohnDoe' };
Post('playerEntered', playerData);
}
```
Download:
https://www.npmjs.com/package/fetchnui?activeTab=readme