How to use camelcase-keys - 10 common examples

To help you get started, we’ve selected a few camelcase-keys 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 beer-garden / beer-garden / ui / src / actions / role.js View on Github external
.then(res => {
        const normalizedData = camelcaseKeys(res.data);
        dispatch(createRoleSuccess(normalizedData));
        return normalizedData;
      })
      .catch(e => defaultErrorHandler(e, dispatch, createRoleFailure));
github akameco / PixivDeck / app / services / api.js View on Github external
} = await axios.post(AUTH_URL, stringify(data), {
    headers: {
      'X-Client-Hash': md5(moment().format() + HASH_SECRET),
      'X-Client-Time': moment().format(),
    },
    transformResponse: [
      rowData => {
        try {
          return JSON.parse(rowData)
        } catch (error) {
          return rowData
        }
      },
    ],
  })
  return camelcaseKeys(response, { deep: true })
}
github sidewalklabs / commonspace / src / routes / api.ts View on Github external
return401OnUnauthorizedError(async (req: Request, res: Response) => {
            const { user_id: userId } = req.user;
            const study = camelcaseKeys(req.body as Study);
            const { studyId } = req.params;
            if (!(await userIdIsAdminOfStudy(DbPool, studyId, userId))) {
                throw new UnauthorizedError(req.route, userId);
                return;
            }
            const { surveys, surveyors } = study;
            const updatedStudy = await updateStudy(DbPool, { ...study, userId });
            await Promise.all(surveyors.map(s => giveUserStudyAccess(DbPool, s, studyId)));
            if (surveys) {
                await Promise.all(
                    surveys.map(s => updateSurvey(DbPool, camelcaseKeys({ studyId, ...s })))
                );
            }
            res.status(200).send();
        })
    )
github quran / quran.com-frontend / src / redux / reducers / search.ts View on Github external
success: prevState => ({
          ...prevState,
          isLoading: false,
          totalCount: action.payload.total_count,
          totalPages: action.payload.total_pages,
          currentPage: action.payload.current_page,
          perPage: action.payload.per_page,
          took: action.payload.took,
          query: action.payload.query,
          entities: camelcaseKeys(action.payload.results || {}, { deep: true }),
        }),
      });
github sidewalklabs / commonspace / src / stores / applicationState.ts View on Github external
export async function selectNewStudy(study: any) {
    applicationState.currentStudy = study;

    try {
        applicationState.currentStudy.datapoints = camelcaseKeys(
            await getRest(`/api/studies/${study.studyId}/datapoints`)
        );
    } catch (error) {
        setSnackBar('error', `Unable to get study datapoints!`);
        throw error;
    }
}
github beer-garden / beer-garden / ui / src / actions / version.js View on Github external
.then(response => {
        const normalizedData = camelcaseKeys(response.data);
        dispatch(fetchVersionSuccess(normalizedData));
        return normalizedData;
      })
      .catch(e => defaultErrorHandler(e, dispatch, fetchVersionFailure));
github beer-garden / beer-garden / ui / src / actions / auth.js View on Github external
.then(res => {
        const normalizedData = camelcaseKeys(res.data);
        const actionPayload = { isGuest: false, data: normalizedData };
        dispatch(userLoginSuccess(actionPayload));
        return normalizedData;
      })
      .catch(e => defaultErrorHandler(e, dispatch, userLoginFailure));
github quran / quran.com-frontend / src / redux / reducers / suggest.ts View on Github external
success: prevState => ({
          ...prevState,
          results: {
            ...state.results,
            [action.meta.query]: camelcaseKeys(action.payload || {}, {
              deep: true,
            }),
          },
        }),
      });
github akameco / pixiv-app-api / src / index.ts View on Github external
options = options || {}

    if (options.data) {
      options.method = 'post'
      options.headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
      options.data = stringify(decamelizeKeys(options.data))
    }

    if (options.params) {
      options.params = decamelizeKeys(options.params)
    }
    const { data } = await instance(target, options as AxiosRequestConfig)
    this.nextUrl = data && data.next_url ? data.next_url : null
    return this.camelcaseKeys ? camelcaseKeys(data, { deep: true }) : data
  }
}
github quran / quran.com-frontend / src / redux / reducers / chapters.ts View on Github external
success: prevState => ({
          ...prevState,
          entities: {
            ...prevState.entities,
            ...keyBy(
              camelcaseKeys(action.payload.chapters || {}, { deep: true }),
              'id'
            ),
          },
        }),
      });

camelcase-keys

Convert object keys to camel case

MIT
Latest version published 3 months ago

Package Health Score

82 / 100
Full package analysis

Popular camelcase-keys functions