Created
February 4, 2021 14:58
-
-
Save gmatta01/d53fbed36032e7b98e81bb9ba93fabc0 to your computer and use it in GitHub Desktop.
Fetch post image from REST API - WIP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const loadProduct = async() => { | |
try { | |
const prequest = await fetch("https://webtechforce.com/wp-json/wp/v2/posts/7544/?_embed"); | |
// console.log(prequest); | |
if (prequest.status == 200) { | |
let product = await prequest.json(); | |
let product_src = await product._embedded['wp:featuredmedia']; | |
if (typeof(product_src) != "undefined") { | |
} | |
} | |
} catch (e) { | |
// handle error | |
console.error(e) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment