I am using the 3.6.8 version of strapi. I have successfully deployed my strapi backend on heroku. I followed the steps from the latest documentation to integrate cloudinary with strapi. I correctly setup my environment variables too. Now when I am uploading my media in deployed strapi backend, they are not adding to cloudinary. I have followed every step as it is watched videos, but not getting the resullt. Kindly help.
Here is the git repository of my code:
what are you getting from the logs?
Hi Luis, thanks for reaching out. I resolved the issue. I think it was due to I was using older version of strapi. I updated strapi to latest version and again followed the steps and it worked out.
Now I am stuck in another issue. I am hitting a post request to an API. When I hit from postman it is working fine. But when I am hitting it from the deployed version of heroku from my front end. It is showing an error. I hope you can help me
But it is giving error here.
Here is my strapi backend code:
"use strict";
/**
* Order.js controller
*
* @description: A set of functions called "actions" for managing `Order`.
*/
const stripe = require("stripe")(process.env.STRIPE_SK);
module.exports = {
/**
* Create a/an order record.
*
* @return {Object}
*/
create: async (ctx) => {
console.log(ctx.request.body);
const { address, total, products, items, city, token } = JSON.parse(
ctx.request.body
);
const stripeAmount = Math.floor(total * 100);
// charge on stripe
const charge = await stripe.charges.create({
// Transform cents to dollars.
total: stripeAmount,
currency: "pkr",
description: `Order ${new Date()} by ${ctx.state.user._id}`,
source: token,
});
// Register the order in the database
const order = await strapi.services.order.create({
user: ctx.state.user.id,
charge_id: charge.id,
total: stripeAmount,
address,
products,
city,
items,
});
return order;
},
};
const { createCoreController } = require("@strapi/strapi").factories;
module.exports = createCoreController("api::order.order");
and here is my react front-end code:
const response = await axios({
url: `https://enigmatic-island-20911.herokuapp.com/api/orders`,
method: "POST",
headers: userToken && { Authorization: `Bearer ${userToken}` },
body: JSON.stringify({
data: {
total: Number(checkoutProducts.total),
products: checkoutProducts.checkoutItems,
address: data.address,
city: data.city,
token: token.token.id,
items: checkoutProducts.checkoutItems.length,
},
}),
});
if (!response.ok) {
setError(response.statusText);
}