Native Request is a simple module that makes you create native node.\+js requests supports https.


\begin{DoxyItemize}
\item supports HTTPS
\item 0 dependencies
\item use callbacks
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_native_request_README_autotoc_md17959}{}\doxysection{Installation}\label{md_sfcode_node_modules_native_request_README_autotoc_md17959}
Install the dependencies and dev\+Dependencies and start the server.


\begin{DoxyCode}{0}
\DoxyCodeLine{npm install native-\/request }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_native_request_README_autotoc_md17960}{}\doxysection{Usage}\label{md_sfcode_node_modules_native_request_README_autotoc_md17960}
\hypertarget{md_sfcode_node_modules_native_request_README_autotoc_md17961}{}\doxysubsection{GET request}\label{md_sfcode_node_modules_native_request_README_autotoc_md17961}

\begin{DoxyItemize}
\item request.\+get(path, headers, callback)
\item request.\+get(path, callback)
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{let request = require('native-\/request');}
\DoxyCodeLine{request.get('https://github.com', function(err, data, status, headers) \{}
\DoxyCodeLine{    if (err) \{}
\DoxyCodeLine{        throw err;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{    console.log(status); //200}
\DoxyCodeLine{    console.log(data); // page content}
\DoxyCodeLine{    console.log(headers); // response headers}
\DoxyCodeLine{\}); }

\end{DoxyCode}
 To add custom {\bfseries{headers}} just do like this\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{let request = require('native-\/request');}
\DoxyCodeLine{}
\DoxyCodeLine{let headers = \{}
\DoxyCodeLine{    "{}content-\/type"{}: "{}plain/text"{}}
\DoxyCodeLine{\}}
\DoxyCodeLine{request.get('https://github.com', headers, function(err, data, status, headers) \{}
\DoxyCodeLine{    if (err) \{}
\DoxyCodeLine{        throw err;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{    console.log(status); //200}
\DoxyCodeLine{    console.log(data); // page content}
\DoxyCodeLine{    console.log(headers); // response headers}
\DoxyCodeLine{\}); }

\end{DoxyCode}
 \hypertarget{md_sfcode_node_modules_native_request_README_autotoc_md17962}{}\doxysubsection{POST request}\label{md_sfcode_node_modules_native_request_README_autotoc_md17962}

\begin{DoxyItemize}
\item request.\+post(path, callback)
\item request.\+post(path, data, callback)
\item request.\+post(path, data, headers, callback)
\end{DoxyItemize}

To send an empty {\bfseries{post}}\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{let request = require('native-\/request');}
\DoxyCodeLine{request.post('https://github.com', function(err, data, status, headers) \{}
\DoxyCodeLine{    if (err) \{}
\DoxyCodeLine{        throw err;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{    console.log(status); //200}
\DoxyCodeLine{    console.log(data); // page content}
\DoxyCodeLine{    console.log(headers); // response headers}
\DoxyCodeLine{\}); }

\end{DoxyCode}


With headers and data\+:


\begin{DoxyCode}{0}
\DoxyCodeLine{let request = require('native-\/request');}
\DoxyCodeLine{}
\DoxyCodeLine{let data = \{}
\DoxyCodeLine{    "{}example"{}: true,}
\DoxyCodeLine{\}}
\DoxyCodeLine{let headers = \{}
\DoxyCodeLine{    "{}content-\/type"{}: "{}plain/text"{}}
\DoxyCodeLine{\}}
\DoxyCodeLine{request.post('https://github.com', data, headers, function(err, data, status, headers) \{}
\DoxyCodeLine{    if (err) \{}
\DoxyCodeLine{        throw err;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{    console.log(status); //200}
\DoxyCodeLine{    console.log(data); // page content}
\DoxyCodeLine{    console.log(headers); // response headers}
\DoxyCodeLine{\}); }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_native_request_README_autotoc_md17963}{}\doxysubsection{Custom request}\label{md_sfcode_node_modules_native_request_README_autotoc_md17963}

\begin{DoxyItemize}
\item $\ast$.request(path, method, callback)
\item $\ast$.request(path, method,data, callback)
\item $\ast$.request(path, method, data, headers, callback) To send a {\bfseries{PUT}} request\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{let request = require('native-\/request');}
\DoxyCodeLine{request.request('https://github.com', 'PUT', function(err, data, status, headers) \{}
\DoxyCodeLine{    if (err) \{}
\DoxyCodeLine{        throw err;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{    console.log(status); //200}
\DoxyCodeLine{    console.log(data); // page content}
\DoxyCodeLine{    console.log(headers); // response headers}
\DoxyCodeLine{\}); }

\end{DoxyCode}
 With headers and data\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{let request = require('native-\/request');}
\DoxyCodeLine{}
\DoxyCodeLine{let data = \{}
\DoxyCodeLine{    "{}example"{}: true,}
\DoxyCodeLine{\}}
\DoxyCodeLine{let headers = \{}
\DoxyCodeLine{    "{}content-\/type"{}: "{}plain/text"{}}
\DoxyCodeLine{\}}
\DoxyCodeLine{request.request('https://github.com','PUT', data, headers, function(err, data, status, headers) \{}
\DoxyCodeLine{    if (err) \{}
\DoxyCodeLine{        throw err;}
\DoxyCodeLine{    \}}
\DoxyCodeLine{    console.log(status); //200}
\DoxyCodeLine{    console.log(data); // page content}
\DoxyCodeLine{    console.log(headers); // response headers}
\DoxyCodeLine{\}); }

\end{DoxyCode}
 
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_native_request_README_autotoc_md17964}{}\doxysubsection{License}\label{md_sfcode_node_modules_native_request_README_autotoc_md17964}
MIT. Copyright (c) Samuel Marchese. 