github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/build-blockchain-insurance-app-master/web/src/police/api.js (about)

     1  'use strict';
     2  
     3  import fetch from 'isomorphic-fetch';
     4  
     5  export function listTheftClaims() {
     6    return fetch('/police/api/claims', {
     7      method: 'POST',
     8      headers: new Headers({
     9        'Content-Type': 'application/json'
    10      })
    11    }).then(async res => {
    12      const claims = await res.json();
    13      return claims;
    14    });
    15  }
    16  
    17  export function processTheftClaim(contractUuid, uuid, isTheft, fileReference) {
    18    return fetch('/police/api/process-claim', {
    19      method: 'POST',
    20      headers: new Headers({
    21        'Content-Type': 'application/json'
    22      }),
    23      body: JSON.stringify({
    24        contractUuid, uuid, isTheft, fileReference
    25      })
    26    }).then(async res => {
    27      const response = await res.json();
    28      if (response.success) {
    29        return response.uuid;
    30      } else {
    31        throw new Error(response.error);
    32      }
    33    });
    34  }