Hello Dear Moralis Members, I have An Issue That I Need Help To Get It Fixed

Hello There!
I Have Been Working For 10 Days In A Raw To Take An Old Java Script Game To The New World Of Block Chain. I Have Learned HTML, CSS, Swift, And C Programming Languages So Editing And Developing With JavaScript Is Very Nice, Specially When Its Combined With Such A Grate Platform…
I Have Successfully Applied A LOT Of Moralis In My Project But Now I am Facing An Issue.
I Would Like To Add The Items That The Player Owns To Moralis Server… I Am Successfuly Added Data Like Money Count, Level, Current Map, Current Power And More To The Moralis Server
But The Items Giving Me An Error.

Succesfully Added Item Name, And Propperties Of Item When Its Being Picked Up, But The Only Thing Missing Is An Object That Seem To Be A Problematic Object When It Comes To syncing With Moralis Server.

That Is The Function:

async function checkCloudBackExist ()
	//check if existing player
	let user = Moralis.User.current();
	let query = new Moralis.Query('PlayerBpMRL');
	query.equalTo("player", user.get("ethAddress"));
	const results = await query.find();
	//if 0 results lenght for logged in user, means its their first time Picking Up An Item .
	if (results.length == 0) {
        //create tables for the first time.
		console.log(" create tables for the first time.")
		const PlayerBpMRL = Moralis.Object.extend("PlayerBpMRL");
		const playerBpMRL = new PlayerBpMRL();
//Whatitem.name = NameString
		playerBpMRL.set("EquipName" ,Whatitem.name);

	//The Problematic Object Line Is This:	playerBpMRL.set("EquipIMGsrc" ,Whatitem.img);

//Whatitem.des = Array With Properties
		playerBpMRL.set("EquipDES" ,Whatitem.des);

//Whatitem.properties = Another Array With Properties
		playerBpMRL.set("EquipProperties" ,Whatitem.properties);

			await playerBpMRL.save();


Every Thing Works Great Except This Line: playerBpMRL.set(“EquipIMGsrc” ,Whatitem.img);
When Its Not Noted Line It Returns An Error:!

Screenshot 2021-12-10 145817|690x408

As You Can See, When I Console.log(Whatitem.img)
It Shows That Whatitem.img Contains:

But Not As A String Because String Shows As White Text, And Also I Tried Using It As A String But Thats Not What The Code Needs To Work With.
When I Try To Console.log(typeof Whatitem.img) It Print Object…
But Also When i Console.log(typeof Whatitem.properties) I Get Object But Still Whatitem.properties does updating perfectly to Moralis Servers, While .img Gives an Error And Undifined.
As I Said I Am Pretty New To JS And Tottaly New With Moralis So I Would Like To Get An Idea Of What Am I Doing Wrong Or How I Can Fix That Issue.
I Made Such A Great Progress And A Lot Of People I Know Would Like To Start Play The Game I Am Developing Here.

you could try to use console.log(JSON.stringify(Whatitem.img))

1 Like

Return an empty value:

{} "Json.stringify Of What item"

Maybe I’ll Expand A bit:

			case 1:
//in case playe able to add the dropped item to his BackPack 
				var pos = (this.empty_list["Equip"].splice(0, 1))[0];
				Whatitem = new EquipmentItem(thing.name, thing.curr_res);			
				this.backpack["Equip"][pos] = Whatitem;



//Define Equipment Properties
function EquipmentItem(name, img) {
	this.name = name;
	this.img = img;
	this.properties = window.properties_factory.getProperties(this.name);
	this.des = window.des_factory.equipmentDes(this.properties);

As I Have Mentioned:
Whatitem.name, Whatitem.des & Whatitem.Properties Are Successfully Sets Into Moralis.
Only Whatitem.img Causing The Error.
At the end The Whatitem Contains:
Screenshot 2021-12-11 073241

Any Suggestions?

what type of data is that img? it doesn’t look like a simple string at a first look

1 Like

First Thing I Really Appreciate Your Effort!
Well, when I console logging Typeof It Says: Object.
That Is Not A Simple String But It Seems Its Also Not The Image File Its Self…
Then I am Pretty Sure Its Just Pointing To The Image As Of Its Logging:

<img src="things/heitangshan_0.png">

Some How Its not Just A String…
Do You Know Any Way, How Can I Check Exactly What Kind Of Data Is It?
I Tried A Huge Amount Of Methods By Now :no_mouth:

what do you save in that object variable n the first place?

1 Like

I Am Not The One Who Created This Project In The First Place, But It Really Enhanced A LOT By Me So I Am Really Familiar With It…
But This img Object Really Made Me An Headache
The Project It Self Contains 16 JavaScript Files, And As I Said JS Is Pretty New For Me.
But What I Do Know And I Am Pretty Sure I Am Close To Find The Solution Is:
Whatitem = New Equipment(thing.name, thing.curr_res)
And Curr_Res Means Current Resource…
In The Resource JS:

		// things Folder Load
		this.loadResurces(this.things, this.things_res_data, "things");

And Then This Line:

    this.things_res_data = [{name: "shuangyiren", total: 1}, {name: "heitangshan", total: 1}]

Maybe The Object Whatitem.img Does Contain The Image Now I Am Not Sure
Do You Know A Way How Would I Verify If It Does Contain The Image File?
And If It Is, Should I Upload The Image To Moralis Server?
Maybe I’ll Consider Another Way Of Pulling The Name Of The ITEM Only And Then In The Code, Tell That The img Should Match With The Name Of It.
Thank You CryptoKid You Are The Best!!! Is There A Way I Can Contact You Privately Or It Is Unwelcomed In Here?
I Have A Few Crypto Projects I Am Participating In And I Would Like To Share It With You.

in the image below this text, it looks like you have the entire object listed, but you have to click on those arrows to see more of the object

maybe is not a good idea to save directly the image file to db, you could upload them to IPFS for example

you can contact me on Discord if you want