Skip to content

Commit

Permalink
Rename files and functions
Browse files Browse the repository at this point in the history
Rename from hello to getWooProducts
  • Loading branch information
w3bdesign committed May 11, 2020
1 parent d25d2e4 commit 9bab6c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nextjs-woocommerce",
"version": "1.0.0",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions pages/api/hello.js → pages/api/getWooProducts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const WooCommerce = new WooCommerceRestApi({
version: 'wc/v3',
});

function getProducts() {
return WooCommerce.get('products');
async function getProductsFromRest() {
return await WooCommerce.get('products');
}

export async function Hello(req, res) {
const WooProducts = await getProducts();
export async function getWooProducts(req, res) {
const WooProducts = getProductsFromRest();
res.status(200).json(WooProducts.data);
}

export default Hello;
export default getWooProducts;
2 changes: 1 addition & 1 deletion pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function HomePage(props) {
// Should we use getServerSideProps?

export async function getStaticProps(context) {
const posts = await fetch(`${process.env.ServerUrl}/api/hello`)
const posts = await fetch(`${process.env.ServerUrl}/api/getWooProducts`)
.then((res) => res.json())
.catch((error) => console.log(error));

Expand Down

0 comments on commit 9bab6c6

Please sign in to comment.