customAttribute not visible #8315
Unanswered
arthurcornelio88
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Dear community,
I'm new by here and very fresh in Medusa's implementation. Trying to implement the medusa marketplace. Backend, storefront, all good.
Following the receipt, I'm blocked in the request part (api routes). A priori, I can do the request, but my "customAttribute" is not appearing.
import Medusa from "@medusajs/medusa-js";
import dotenv from "dotenv";
`
dotenv.config();
const medusa = new Medusa({
baseUrl: process.env.MEDUSA_BACKEND_URL,
maxRetries: 3,
});
async function createProductWithAuth() {
const { access_token: jwt_token } = await medusa.admin.auth.getToken({
email: process.env.ADMIN_EMAIL,
password: process.env.ADMIN_PASSWORD,
});
try {
const uniqueHandle = orgao-${Date.now()}; // Generate a unique handle
} catch (error) {
if (error.response) {
console.error("Error response data:", error.response.data);
if (error.response.status === 401) {
console.error("Authentication failed. Please check your API token and try again.");
} else {
console.error("Error creating product:", error.message || error);
}
} else {
console.error("Error creating product:", error.message || error);
}
}
}
createProductWithAuth();
`
output :
What am I'm missing ?
Trying to solve it alone, I got confused with migrations. I started with the Option 2, "Write migration file". No erros, but no "customAttribute" in the Product Entity. Then, I tried the option 1 too, because maybe I should apply the datasource.js to connect to my PostgreSQL database...:
`require("dotenv").config();
const { DataSource } = require("typeorm");
const AppDataSource = new DataSource({
type: "postgres",
host: "localhost",
port: 5432,
username: process.env.ADMIN_USERNAME,
password: process.env.ADMIN_PASSWORD,
database: process.env.DATABASE_NAME,
entities: [
"dist/models/.js",
],
migrations: [
"dist/migrations/.js",
],
});
AppDataSource.initialize().then(() => {
console.log('Entities:', AppDataSource.entityMetadatas.map(meta => meta.name));
}).catch((err) => {
console.error('Error during Data Source initialization:', err);
});
module.exports = {
datasource: AppDataSource,
};
`
When running it, got errors all time, I'm on this one :
No idea why "images" is appearing... any ideas ?
Don't hesitate to ask more about my config.
Thanks in advance !
Beta Was this translation helpful? Give feedback.
All reactions