GithubHelp home page GithubHelp logo

madfishapipractice's Introduction

MadFish API : 100Devs Practice

An API coding practice with Node and Express making the 10 Genera of common endemic freshwater fish available.

Table of contents

Overview

The challenge

Create an API using Node and Express to serve up some data. Users can use the text-input and button to get formatted client-side display, or the url https://madfish-api-100devs.herokuapp.com/api/fishGenus to fetch information from a fish.json file

  • Gain familiarity and comfort using Node and Express to create an API capable of Read (GET) functionality
  • Practice pushing to git and to Heroku for a live build.
  • Continue to gain experience organizing code
  • In addition to the base build, I added a JSON.parse(readFileSync()) to separate the json object from the server.js and main.js code

My process

Straight forward Node and Express app following past examples of creating a server in Node and utilizing Express functionality to make the code more readable.

I preferred to have my data file (fish.json) separated from my server code. A little Googling revealed how to use the readFileSync from the 'fs' module, along with JSON.parse() to make that happen.

On top of having the user by able to enter a Madagascar Fish genus in the url to facilitate a GET request and have a three parameter object returned, I wanted to practice using the '/public' folder to have client-side JavaScript available to the user.

Changes were pushed to a github repository and then, when a function build was completed, pushed to Heroku.

Built with

What I learned

While starting a Node and Express app is fairly straight forward, passing data back and forth between client-side JavaScript and server-side JavaScript you really need to pay attention to the json formatting.

That handling a 404 error is not as straight forward as I thought it might be (see Continued development)

Continued development

I'd like to handle a 404 error a little more gracefully than just stranding the user. This would be implemented to handle an unknown or mis-typed fish genus.

Author

madfishapipractice's People

Contributors

alekseisaunders avatar

Stargazers

Roman avatar

Watchers

 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.