JSPM

is-json-request

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q37196F
  • License MIT

Check if the current request is json, express js, next js, any node js server side code.

Package Exports

  • is-json-request

Readme

is-json-request

Build Status

Check if the current request is json, express js, next js, any node js server side code. (supports module and commonJS).

https://shadiabuhilal.github.io/is-json-request/


Usage

import is-json-request

import { isJsonReq, isGetReq, isPostReq, isPutReq, isDeleteReq } from 'is-json-request';

Or

require is-json-request

const { isJsonReq, isGetReq, isPostReq, isPutReq, isDeleteReq } = require('is-json-request');

isJsonReq

This function checks if the current request is a json request or not.

Example:

if (isJsonReq(req)) {
  // Is a JSON request
}

isGetReq

This function checks if the current request is a http GET method request or not.

Example:

if (isGetReq(req)) {
  // Is a HTTP GET method request
}

isPostReq

This function checks if the current request is a http POST method request or not.

Example:

if (isPostReq(req)) {
  // Is a HTTP POST method request
}

isPutReq

This function checks if the current request is a http PUT method request or not.

Example:

if (isPutReq(req)) {
  // Is a HTTP PUT method request
}

isDeleteReq

This function checks if the current request is a http DELETE method request or not.

Example:

if (isDeleteReq(req)) {
  // Is a HTTP DELETE method request
}