What's wrong with my app?

#1

Calling getFile() returns [object Promise]. I have never been able to putFile() and getFile() successfully - success would be returning a string.

Here are some clues:

1.When I’m logged into my Blockstack app, I can’t log into Blockstack Forum.

I get to the last step of logging into the Blockstack Forum, and right before I can refresh the page to view posts, the pop up login screen gives an error about auth.

2.When I’m logged into Blockstack Forum, my logged in account does not show up in my Blockstack app’s Connect dialog.

3.The console is

[DEBUG] connectToGaiaHub: https://hub.blockstack.org/hub_info
logger.ts:41 
[DEBUG] uploadToGaiaHub: uploading profile.json to https://hub.blockstack.org

And here is putFile + getFile:

$('#btn').click(function() {

	userSession.putFile("profile.json", document.getElementById("textarea").value, {
    		encrypt: false
	});

	document.getElementById("entries").innerHTML = userSession.getFile("profile.json",{ decrypt: false });
										   
	const GetFileOptions = {
			decrypt: false
	};				

}



#2

You can search the usage of JS Promise.

userSession.getFile("a.json", options).then((content)=>{
    console.log(content)
})

getFile is an async function, you should call it by Promise

3 Likes
#3

Learn async/await. It pays dividends in the future.

await getFile()
1 Like
#4

Gavin, you are beautiful.