Git Product home page Git Product logo

uncaught-in-promise-typeerror-data.foreach-is-not-a-function's People

uncaught-in-promise-typeerror-data.foreach-is-not-a-function's Issues

Uncaught-in-promise-TypeError-data.forEach-is-not-a-function

JSON:
{
"Meta Data": {
"1. Information": "US Stock Quotes",
"2. Notes": "IEX Real-Time",
"3. Time Zone": "US/Eastern"
},
"Stock Batch Quotes": [
{
"1. symbol": "JRJC",
"2. open": "1.8500",
"3. high": "1.8800",
"4. low": "1.8200",
"5. price": "1.8800",
"6. volume": "8747",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "VNET",
"2. open": "9.1000",
"3. high": "9.7900",
"4. low": "8.2200",
"5. price": "9.0350",
"6. volume": "1411873",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "PIH",
"2. open": "6.9500",
"3. high": "7.1000",
"4. low": "6.9500",
"5. price": "6.9500",
"6. volume": "565",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "AKAM",
"2. open": "71.2600",
"3. high": "71.6150",
"4. low": "70.9000",
"5. price": "71.4400",
"6. volume": "1459190",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "BIDU",
"2. open": "221.0000",
"3. high": "225.0690",
"4. low": "217.0890",
"5. price": "222.6700",
"6. volume": "5502202",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "CARB",
"2. open": "39.4500",
"3. high": "39.7000",
"4. low": "38.6750",
"5. price": "39.4000",
"6. volume": "312468",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "CCOI",
"2. open": "52.8500",
"3. high": "53.1000",
"4. low": "52.1000",
"5. price": "52.7000",
"6. volume": "190260",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "CCIH",
"2. open": "1.1900",
"3. high": "1.2900",
"4. low": "1.1600",
"5. price": "1.1670",
"6. volume": "338907",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "WIFI",
"2. open": "31.0500",
"3. high": "31.1600",
"4. low": "29.9700",
"5. price": "31.0200",
"6. volume": "346579",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
},
{
"1. symbol": "BCOR",
"2. open": "34.7500",
"3. high": "35.1000",
"4. low": "34.2000",
"5. price": "34.5500",
"6. volume": "280794",
"7. timestamp": "2018-08-17 16:00:00 EST",
"8. currency": "USD"
}
]
}

Script:

document.getElementById('api').addEventListener('click', getapi);

function getapi(){
  fetch('https://www.alphavantage.co/query?function=BATCH_QUOTES_US&symbols=PIH,VNET,AGTK,AKAM,BIDU,BCOR,WIFI,BRNW,CARB,JRJC,CCIH,CHICF,CCOI,CXDO,CRWG&apikey=JP6X8PJ2P228H76U')
  .then((res) => res.json())
  .then((data) => {
    let output = '<h2>Stocks</h2>';
    data.forEach(function(stocks){
      output += `
      <ul>
        <li>Symbol: ${stocks.symbol}</li>
        <li>Open: ${stocks.open}</li>
        <li>Low: ${stocks.low}</li>
        <li>Price: ${stocks.price}</li>
        <li>Volume: ${stocks.volume}</li>
      </ul>
      `;
    });
    document.getElementById('demo').innerHTML=output;
  })
}

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.