JSON example

by sabbin

JavaScript

fetch('https://api.myjson.com/bins/845sm', {
    method: 'GET'
  })
  .then((response)=>response.json())
  .then((responseJson) => {
    if (responseJson.errorCode === '00') {
      const roleList = responseJson.roleList.map((element) => element.roleDescription);
      console.log(roleList)
    } else {
      alert("Error Fetching roles" + responseJson.errorMsg);
    }
  })
  .catch((error) => {
    console.error(error);
  });