Skip to content

LucidThought/Vue3-Typescript-API-Communication

Repository files navigation

Summary

This project is a simple implementation of a front-end system written in Vue3 using 'script setup' and the composition API; it takes advantage of the benefits TypeScript provides. It communicates with a back-end API uing Axios an a pre-shared key (obtained from openexchangerates.org, instructions below). This project was initially provided as a job interview challenge to demonstrate JavaScript knowledge.

To run this project locally (after installing the npm package manager on your machine):

  1. First you need to register for an API key at https://openexchangerates.org/ (Click "Sign Up" and then use the 'Free Plan' link above the prices for paid plans)
  2. After signing up you will get an API key to use with this project. From your account on the site go to 'App IDs' and copy your App ID
  3. Paste your App ID over the CHANGE_ME text in the src/services/constants.ts file
  4. Now that you have you App ID configured, you can install packages with npm i at the terminal (Assuming you have npm installed on your local computer) and then npm run dev to start the application.
  5. The terminal will show you what port on localhost the project is running!

Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 <script setup> SFCs, check out the script setup docs to learn more.

Axios for External Requests

In this project the Axios package is used to communicate with an external AI (in this case to openexchangerates.org). This is not the only option for making requests to external APIs, but Axios provides a simple and straightforward interface for making these requests and dealing with responses.

Recommended IDE Setup

Type Support For .vue Imports in TS

Since TypeScript cannot handle type information for .vue imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in .vue imports (for example to get props validation when using manual h(...) calls), you can enable Volar's Take Over mode by following these steps:

  1. Run Extensions: Show Built-in Extensions from VS Code's command palette, look for TypeScript and JavaScript Language Features, then right click and select Disable (Workspace). By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
  2. Reload the VS Code window by running Developer: Reload Window from the command palette.

You can learn more about Take Over mode here.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published