The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Get Data From An API With windowfetch

TODO: Pull subtitle into page object

This is how I'm pulling data from a basic API:

code_start_default_section code_end_default_section

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Get Data From An API With windowfetch

-- p

This is how I'm pulling data from a basic API:

-- code/
-- javascript

function getCurrentState() {
    let fetchUrl = 'https://example.com/some-api.json'
    return window.fetch(fetchUrl)
    .then(response => response.json())
    .then(response => console.log(response.someKey))
}

getCurrentState()

-- /code

-- p

This works with a promise which I'm not totally sure about how you would use it with a return, but this gets you there for a start.

-- p

The payload from the api should be:

-- code/
-- json

{ someKey: "some Value"}

-- /code


-- categories
-- JavaScript

-- metadata
-- date: 2021-08-13 13:19:19
-- id: 20eokqsg
-- status: scratch
-- type: post
-- SCRUBBED_NEO: false
-- site: aws