Default Theme Dark Theme
Tornado Logo
Tornado has become Phenix Design System

Connect [API Handler] - Tornado UI

Connect is an API Handler using async/ await and fetch methods

Tornado Connect

Connect is an API Handler using async/ await and fetch methods with authentication techniques for Basic, OAuth, Bearer, Digest etc and its always return a Promise JSON Data or Error if something goes wrong.

//======> Import Connect Method <=======//
import Connect from './Base/Connect';
//======> Typescript Usage <=======//
Connect({options});
//======> Global Usage <=======//
Tornado.connect({options});

Basic API Connect

an example for get data from API URL without any authentication.

//=====> Connect API Handler <=====//
Connect ({
url : apiurl, //===> API URL
method : "GET", //===> Request Method
}).then(response => {
//====> Return Data as Json and Print it in Console <===//
console.log(response);
}).catch(error => {
/*===> Promise To Catch Errors <===*/
console.error(error);
});

Bearer Authentication

an example for get data from API URL with Bearer Authentication Key.

//=====> Connect With Bearer Authentication Key <=====//
Connect ({
url : apiurl, //===> API URL
method : "GET", //===> Request Method
//===> Authntication <===//
authnticate : "Bearer",
authnticateKey : "swnGhwBFZJ2qGQGXiSz5MUeSLllIrmFP",
}).then(response => {
//====> Return Data as Json and Print it in Console <===//
console.log(response);
}).catch(error => {
/*===> Promise To Catch Errors <===*/
console.error(error);
});

Copyright (c) 2016-present, Tornado UI Licensed under the terms of the MIT License.