當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript web-request.json函數代碼示例

本文整理匯總了TypeScript中web-request.json函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript json函數的具體用法?TypeScript json怎麽用?TypeScript json使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了json函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: init

  async init(investor: Investor): Promise<KycInitResult> {
    const id = investor.id.toHexString();
    const hash = base64encode(bcrypt.hashSync(id + config.kyc.apiSecret));

    const kycOptions = {
      baseUrl: this.baseUrl,
      method: 'POST',
      auth: {
        user: this.apiToken,
        password: this.apiSecret
      },
      headers: {
        'User-Agent': 'JINCOR ICO/1.0.0'
      },
      body: {
        merchantIdScanReference: uuid.v4(),
        successUrl: `${ config.app.apiUrl }/kyc/uploaded/${ id }/${ hash }`,
        errorUrl: `${ config.app.frontendUrl }/dashboard/verification/failure`,
        callbackUrl: `${ config.app.apiUrl }/kyc/callback`,
        customerId: investor.email,
        authorizationTokenLifetime: this.defaultTokenLifetime
      }
    };

    return await request.json<KycInitResult>('/initiateNetverify', kycOptions);
  }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:26,代碼來源:kyc.client.ts

示例2: validateVerification

  async validateVerification(method: string, id: string, input: ValidateVerificationInput): Promise<ValidationResult> {
    try {
      return await request.json<ValidationResult>(`/methods/${ method }/verifiers/${ id }/actions/validate`, {
        baseUrl: this.baseUrl,
        auth: {
          bearer: this.tenantToken
        },
        method: 'POST',
        body: input
      });
    } catch (e) {
      if (e.statusCode === 422) {
        if (e.response.body.data.attempts >= config.verify.maxAttempts) {
          await this.invalidateVerification(method, id);
          throw new MaxVerificationsAttemptsReached('You have used all attempts to enter code');
        }

        throw new NotCorrectVerificationCode('Not correct code');
      }

      if (e.statusCode === 404) {
        throw new VerificationIsNotFound('Code was expired or not found. Please retry');
      }

      throw e;
    }
  }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:27,代碼來源:verify.client.ts

示例3: resolve

 return new Promise<LandingsdataByLandingdate[]>((resolve, reject) => {
     const url = (window.location.origin + '/api/landingsdata');
     WebRequest.json<LandingsdataResponse>(url + params)
         .then(response => {
             resolve(transformLandingsdatoReponse(response))
         })
         .catch(rejection => reject(rejection));
 });
開發者ID:computerlove,項目名稱:Fiskeoversikt,代碼行數:8,代碼來源:server.ts

示例4: deleteUser

 async deleteUser(login: string): Promise<void> {
   return await request.json<void>(`/user/${ login }`, {
     baseUrl: this.baseUrl,
     method: 'DELETE',
     headers: {
       'authorization': `Bearer ${ this.tenantToken }`
     }
   });
 }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:9,代碼來源:auth.client.ts

示例5: logoutTenant

 async logoutTenant(token: string): Promise<void> {
   await request.json<TenantVerificationResult>('/tenant/logout', {
     baseUrl: this.baseUrl,
     method: 'POST',
     body: {
       token
     }
   });
 }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:9,代碼來源:auth.client.ts

示例6: verifyTenantToken

 async verifyTenantToken(token: string): Promise<TenantVerificationResult> {
   return (await request.json<TenantVerificationResponse>('/tenant/verify', {
     baseUrl: this.baseUrl,
     method: 'POST',
     body: {
       token
     }
   })).decoded;
 }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:9,代碼來源:auth.client.ts

示例7: invalidateVerification

 async invalidateVerification(method: string, id: string): Promise<void> {
   await request.json<Result>(`/methods/${ method }/verifiers/${ id }`, {
     baseUrl: this.baseUrl,
     auth: {
       bearer: this.tenantToken
     },
     method: 'DELETE'
   });
 }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:9,代碼來源:verify.client.ts

示例8: verifyUserToken

 async verifyUserToken(token: string): Promise<UserVerificationResult> {
   return (await request.json<UserVerificationResponse>('/auth/verify', {
     baseUrl: this.baseUrl,
     method: 'POST',
     headers: {
       'authorization': `Bearer ${ this.tenantToken }`
     },
     body: { token }
   })).decoded;
 }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:10,代碼來源:auth.client.ts

示例9: loginUser

 async loginUser(data: UserLoginData): Promise<AccessTokenResponse> {
   return await request.json<AccessTokenResponse>('/auth', {
     baseUrl: this.baseUrl,
     method: 'POST',
     headers: {
       'authorization': `Bearer ${ this.tenantToken }`
     },
     body: data
   });
 }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:10,代碼來源:auth.client.ts

示例10: loginTenant

 async loginTenant(email: string, password: string): Promise<AccessTokenResponse> {
   return await request.json<AccessTokenResponse>('/tenant/login', {
     baseUrl: this.baseUrl,
     method: 'POST',
     body: {
       email,
       password
     }
   });
 }
開發者ID:Norestlabs-Mariya,項目名稱:backend-ico-dashboard,代碼行數:10,代碼來源:auth.client.ts


注:本文中的web-request.json函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。