# useCurrency

# Features

useCurrency composable can be used for:

  • Change selected currency.
  • Get selected currency from cookies.

# API

  • change - function for changing and saving selected currency to Cookies. This method accepts a single params object. The params has the following options:

    • currency: Currency
    type Currency = {
      name: string;
      label: string;
      iso?: string;
    }
    
  • currencies - contains all configured currencies.

    Currency[]
    
  • error: UseCurrencyErrors - a reactive object containing the error message, if changeCurrency failed for any reason.

    interface UseCurrencyErrors {
      change: Error | null;
    }
    

# Example

import { useCurrency } from '@vsf-enterprise/commercetools';

export default {
  setup () {
    const { currency, change } = useCurrency();

    return {
      currency,
      change
    };
  }
}