Untitled

 avatar
unknown
javascript
2 years ago
813 B
2
Indexable
window.getRecord = function getRecord() {
    const currentCharacterId = sessionStorage.getItem('currentCharacterId');
    const myHeaders = new Headers();
    myHeaders.append('Content-Type', 'application/json');
    const requestOptions = {
      method: 'get',
      headers: myHeaders,
      redirect: 'follow',
    };

    const record = fetch(
      `https://v1.nocodeapi.com/makebelieveme/airtable/nmeOnHAeFloOUpCL?tableName=Characters&filterByFormula={RECORD_ID}="${currentCharacterId}"`,
      requestOptions
    )
      .then((response) => response.json())
      .then((result) => {
        // might need to be refactored to get the most recent version, rather than just index 0
        return result['records'][0];
      })
      .catch((error) => console.log('error', error));

    return record;
  };
Editor is loading...