Advertisement
pstudart

http API CALL from class

Oct 17th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import {WebPartContext} from "@microsoft/sp-webpart-base";
  2. import { EnvironmentType } from "@microsoft/sp-core-library";
  3. import { HttpClient } from "@microsoft/sp-http";
  4.  
  5. export class LotusServiceManager{
  6. public context: WebPartContext;
  7. public environmentType: EnvironmentType;
  8.  
  9.  
  10. public Setup(context: WebPartContext, environmentType: EnvironmentType):void {
  11. this.context = context;
  12. this.environmentType = environmentType;
  13. }
  14.  
  15. public checkURL(LotusURL: string): Promise<any> {
  16. return this.context.httpClient.get(`${LotusURL}`,
  17. HttpClient.configurations.v1).then(response => {
  18. return response.json();
  19. }).catch(error => {
  20. return Promise.reject(error);
  21. });
  22. }
  23.  
  24.  
  25.  
  26. }
  27.  
  28. const LotusService = new LotusServiceManager();
  29. export default LotusService;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement