Added CORS configuration to api call and simplified JSON handling