PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, September 25, 2022

[FIXED] How do I check if a proton chain user exists properly and reliably from the front-end?

 September 25, 2022     api, blockchain, javascript     No comments   

Issue

If I go to https://protonscan.io/accounts/username I get a 400 response for a user that doesn't exist and a 200 response for a user that exists on get_account (https://proton.greymass.com/v1/chain/get_account)

How do we check this properly and reliably and "Nice to have": How do we get the avatar for that user or other information, all from the front end?

Thanks.


Solution

So the solution I chose is this:

let userProvided; // here I get the username from the front-end
// then I fetch the user's data
fetch('https://proton.eosusa.news/v2/state/get_account?account=' + userProvided).then(response => {
  return response.json();
}).then(data => {
// after the data is parsed into an object we can use it here
   console.log(data);
});


Answered By - Lucian
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing