getTerrainRgb returns Promise { <state>: "rejected" }
See original GitHub issueProblem:
the getTerrainRgb method returns a rejected Promise
I’m calling the following inside a useEffect() React hook:
const ioToken = <mytoken>
const tgeo = new ThreeGeo({
tokenMapbox: ioToken,
});
async function fetchGeo() {
const terrain = await tgeo.getTerrainVector(
[0.0, 0.0], // [lat, lng]
1.0, // radius of bounding circle (km)
13) // zoom resolution
fgRef.current.scene().add(terrain)
};
fetchGeo();
what happens
The getTerrainRgb method returns a rejected Promise
additional comments The fgRef.current.scene().add() method is from react-force-graph.
I’ve checked that the mapbox API token is valid.
Any ideas why it’s not working?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
When Promise state become rejected or resolved
The promise that is resolved is not the original promise, but the promise returned by then . The original promise is indeed rejected, ......
Read more >Promise.reject() - JavaScript - MDN Web Docs
The Promise.reject() method returns a Promise object that is rejected with a given reason.
Read more >JavaScript Promise Tutorial – How to Resolve or Reject ...
The results will contain a state (fulfilled/rejected) and value, if fulfilled. In case of rejected status, it will return a reason for the...
Read more >JavaScript promise reject() Method - GeeksforGeeks
Return value: It returns the rejected promise with the given reason, either specified by user or via the backend. The examples below illustrate ......
Read more >Error handling with promises - The Modern JavaScript Tutorial
https://uploads.disquscdn.c... In this case, when the callback is executed, reject returns a promise object with updated properties i.e. state = ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@j-devel I can see in the console that the Promise is no longer rejected, so yes, I consider it solved! (I didn’t reply earlier because I encountered another issue - probably not from three-geo - preventing the addition of the terrain to the scene.) Thanks to @Cobertos for the pro debugging and to @j-devel for the fix!
Thanks @Cobertos for feedback!
Addressed in https://github.com/w3reality/es-pack-js/commit/d93a7432a261712ed058540066d603ab06ea21df
Fixed in cda26f3. The latest v1.4.3 build in dist should just work as far as you use them in browsers.
For NodeJS users, I’ve introduced a new flag option instead of implicitly relying on the crude
isNodeJS()method.