How to use the humps.camelizeKeys function in humps

To help you get started, we’ve selected a few humps examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NorikDavtian / semantic-dashboard / src / api / inbox.js View on Github external
export const getEmails = async (pageNo = 1) => {
  const response = await fetch(`${baseUrl}/api/inbox?page=${pageNo}`, {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    }
  });

  if (response.status === 200) {
    const body = await response.json();
    // console.log('response: ', body);
    const res = camelizeKeys(body)
    console.log('RES: ', res);

    return camelizeKeys(body);
  }
  throw new Error('Can not fetch emails');
};
github ello / webapp / src / sagas / requester.js View on Github external
try {
    response = yield call(sagaFetch, endpointPath, options)
  } catch (error) {
    updateRunningFetches(error.response)
    yield fork(handleRequestError, error, action)
    return false
  }

  const { json, serverResponse } = response

  updateRunningFetches(serverResponse)

  payload.serverStatus = serverResponse.status
  if (serverResponse.status === 200 || serverResponse.status === 201) {
    payload.response = camelizeKeys(json)
    const linkPagination = parseLink(serverResponse.headers.get('Link'))
    // for now these need to remain parseInt instead of Number cast
    // due to StreamContainer casting them as number and checking for 0
    // when you do Number(null) it equals 0, thanks javascript!
    linkPagination.totalCount = parseInt(serverResponse.headers.get('X-TotalCount'), 10)
    linkPagination.totalPages = parseInt(serverResponse.headers.get('X-Total-Pages'), 10)
    linkPagination.totalPagesRemaining = parseInt(serverResponse.headers.get('X-Total-Pages-Remaining'), 10)
    payload.pagination = linkPagination
  }
  yield put({ meta, payload, type: SUCCESS })
  yield call(fireSuccessAction)
  return true
}
github outlandishideas / kasia / src / normalisers / postType.js View on Github external
export default function normalisePostType (postType) {
  const schema = Array.isArray(postType) ? arrayOf(postTypeSchema) : postTypeSchema;
  return normalize(humps.camelizeKeys(postType), schema);
};
github outlandishideas / kasia / src / normalisers / revision.js View on Github external
export default function normaliseRevision (revision) {
  const schema = Array.isArray(revision) ? arrayOf(revisionSchema) : revisionSchema;
  return normalize(humps.camelizeKeys(revision), schema);
};
github Flexget / webui / src / utils / fetch.ts View on Github external
export const camelize = (obj: Object | Object[]) =>
  humps.camelizeKeys(obj, {
    separator: '_',
  });
github CodementorIO / nextjs-redux-starter / src / libs / github.js View on Github external
return axios.get(path).then(res => {
      return humps.camelizeKeys(res.data)
    })
  }
github strues / boldr / src / common / state / dux / boldr / actions.js View on Github external
.then(response => {
        const camelizedJson = camelizeKeys(response.body);
        const normalized = normalize(camelizedJson, arrayOf(settingSchema));
        return dispatch(doneLoadSettings(normalized));
      })
      .catch(error => {
github codesandbox / codesandbox-client / packages / app / src / app / pages / Dashboard / Content / SandboxGrid / index.tsx View on Github external
.then(x => {
        const data = camelizeKeys(x.data) as Sandbox;
        this.loadedSandboxes[data.id] = data;
        return data;
      });
  };
github kisi-inc / client-js / src / index.js View on Github external
this.client.interceptors.response.use(response => {
      const newResponse = response;

      newResponse.data = humps.camelizeKeys(response.data);

      return response;
    });
  }

humps

Underscore-to-camelCase converter (and vice versa) for strings and object keys in JavaScript.

MIT
Latest version published 7 years ago

Package Health Score

53 / 100
Full package analysis