Code Monkey home page Code Monkey logo

dio-cryptocurrency-api-integration's Introduction

Digital Innovation One

Requisitando dados de uma API de criptomoedas

Esse exercício abordou conceitos e técnicas de manipulação de APIs, com a integração de uma Single Page Application (SPA) em React com a CoinMarketCap API.


⚔ Desafio

Consumir os recursos da CoinMarketCap API em um frontend.

🛑 Problema

A API RESTful fornecida pela CoinMarketCap não permite a requisição de recursos por JavaScript diretamente no frontend, sendo bloqueada pela configuração do CORS (Cross-Origin Resource Sharing) a fim de proteger a visibilidade da minha API Key.

Making HTTP requests on the client side with Javascript is currently prohibited through CORS configuration. This is to protect your API Key which should not be visible to users of your application so your API Key is not stolen. Secure your API Key by routing calls through your own backend service.

⚠ Tentativa

Para contornar essa questão do CORS, tentei utilizar o [https://cors-anywhere.herokuapp.com/][cors-anywhere], um Node.js app que possibilita requisições cross-origin para qualquer lugar, mas a "solução" se mostrou instável e o acesso à CoinMarketCap API ficava indisponível em alguns momentos.

✅ Solução

Além de criar o frontend, também desenvolvi um middleware na forma de uma aplicação Node.js para realizar a integração entre a CoinMarketCap API e o React app. Esse middleware não apenas me permitiu esconder a minha API Key, mas também restringir os requests através das minhas configurações do CORS, aceitando apenas as requisições com origem em https://leonardosposina.github.io via scripts em navegador.


📷 Screenshots

Cryptocurrency App - Desktop

Cryptocurrency App - Desktop (modal)

Cryptocurrency App - Mobile Cryptocurrency App - Mobile (modal)

Cryptocurrency App - Mobile (horizontal)

Cryptocurrency App - Mobile (horizontal/modal)


Referências

dio-cryptocurrency-api-integration's People

Contributors

leonardosposina avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.