Skip to content

Instantly share code, notes, and snippets.

@gangesh
Created February 4, 2021 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gangesh/d53fbed36032e7b98e81bb9ba93fabc0 to your computer and use it in GitHub Desktop.
Save gangesh/d53fbed36032e7b98e81bb9ba93fabc0 to your computer and use it in GitHub Desktop.
Fetch post image from REST API - WIP
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