ts-sync-request
TypeScript strongly-typed wrapper for sync-request library
Make synchronous http calls in TypeScript
The package exports a SyncRequestService class which has methods to make synchronous GET, POST calls.
sync-request library on npm
ts-sync-request library on npm
Sample usage
TypeScript classes
class Request
{
Email: string;
}
class Response
{
isValid: boolean;
}
Usage
import { SyncRequestService } from 'ts-sync-request/dist';
GET:
let email = "jdoe@xyz.com";
let url = "http://localhost:59039/api/Movies/validateEmail/" + email;
let response = new SyncRequestService().get<Response>(url);
POST:
let url = "http://localhost:59039/api/Movies/validateEmailPost";
let request = new Request();
request.Email = "jdoe@xyz.com";
let response = new SyncRequestService().post<Request, Response>(url, request);