stacks-network / stacks-network/stacks-core
Calling stacks-node-api.mainnet-stacks.co returns a javascript code instead a json file
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.1k
- Forks
- 762
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 76
Description
Describe the bug
Calling stacks-node-api.mainnet-stacks.co returns a javascript code instead a json file
Steps To Reproduce
This function calls the above API:
// reconfigure obtaining consensus hash
bskConfig.network.getConsensusHash = async function() {
//proe
// const httpResponse = await fetch('https://core.blockstack.org/v1/info')
const httpResponse = await fetch(bskConfig.network.coreApiUrl + '/v2/info')
logger.info(httpResponse)
const jsonResponse = await httpResponse.json()
logger.info(jsonResponse)
const lastBlockSeen = SERVER_GLOBALS.lastSeenBlockHeight
if (jsonResponse.stable_burn_block_height + 10 < lastBlockSeen) {
logger.error('operation - getConsensusHash --> stacks-node-api.mainnet-stacks.co is >10 blocks behind the chain tip', {
msgType: 'stale_core',
burn_block_height: jsonResponse.burn_block_height,
coreLastProcessed: jsonResponse.stable_burn_block_height
})
throw new Error('stacks-node-api.mainnet-stacks.co is >10 blocks behind the chain tip')
}
const consensusHash = jsonResponse.pox_consensus
logger.info(operation - getConsensusHash --> Obtained consensus hash ${consensusHash}, {
msgType: 'consensus_hash',
consensusHash
})
logger.info(consensusHash)
return consensusHash
}
Expected behavior
It used return a json file with the information, not a javascript code
Environment (please complete the following information):
- OS: Ubuntu
- Node
- Version of the appropriate binary / software package
Additional context
It returns:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the shown getConsensusHash function and request stacks-node-api.mainnet-stacks.co/v2/info directly, comparing the response headers and body with httpResponse.json() expectations. Trace bskConfig.network.coreApiUrl and the corresponding core API handler in stacks-core; done means the endpoint consistently returns the documented JSON information rather than JavaScript.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, backend, blockchain
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100