Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | soeng kanel |
I am making the HTML5 game with godot engine. and API server using nodejs/expressjs.
here is my code to save the score once game is over.
func game_over():
$EndSound.play()
playing = false
$GameTimer.stop()
$Timer.stop()
set_process(false)
var time = OS.get_datetime()
var milisec = OS.get_ticks_msec()
playerscore.uid = Hanzo.user_info.id
playerscore.score = score
Hanzo.save_score(playerscore, http) #calling function
for coin in $CoinContainer.get_children():
coin.queue_free()
$HUD.show_game_over()
$Player.die()
and here is the function for saving the score on cloud Firestore function
func save_score(fields: Dictionary, http: HTTPRequest) ->void:
var url := "%s/developers/%s/projects/%s" % [HANZO_API_URL, developer_id, pid]
var document := { "fields": fields }
var body := to_json(document)
print("saving doc.");
var error = http.request(url, _get_request_headers(), false, HTTPClient.METHOD_POST, body)
if error != OK:
push_error("An error occurred in the HTTP request.")
first time started the game play then game over → saved score successfully.
after game over I play again the game over-> I got this error message in my chrome console log error.
index.js:8 ERROR: Condition “requesting” is true. Returned:
ERR_BUSY index.js:8 At: scene/main/http_request.cpp:90:request() -
Condition “requesting” is true. Returned: ERR_BUSY
Any recommend to handle this error?