@@ -90,16 +90,16 @@ func doGetRequest(url string, queryParams map[string]interface{}, headers map[st
9090	return  result , nil 
9191}
9292
93- func  doPostRequest (url  string , params  map [string ]interface {}, headers  map [string ]interface {}) (map [string ]interface {}, error ) {
93+ func  doPostRequest (url  string , params  map [string ]interface {}, headers  map [string ]interface {}) (map [string ]interface {}, int ,  error ) {
9494	supertokens .LogDebugMessage (fmt .Sprintf ("POST request to %s, with form fields %v and headers %v" , url , params , headers ))
9595
9696	postBody , err  :=  qs .Marshal (params )
9797	if  err  !=  nil  {
98- 		return  nil , err 
98+ 		return  nil , - 1 ,  err 
9999	}
100100	req , err  :=  http .NewRequest ("POST" , url , bytes .NewBuffer ([]byte (postBody )))
101101	if  err  !=  nil  {
102- 		return  nil , err 
102+ 		return  nil , - 1 ,  err 
103103	}
104104	for  key , value  :=  range  headers  {
105105		req .Header .Set (key , value .(string ))
@@ -110,28 +110,28 @@ func doPostRequest(url string, params map[string]interface{}, headers map[string
110110	client  :=  & http.Client {}
111111	resp , err  :=  client .Do (req )
112112	if  err  !=  nil  {
113- 		return  nil , err 
113+ 		return  nil , resp . StatusCode ,  err 
114114	}
115115	defer  resp .Body .Close ()
116116
117117	body , err  :=  ioutil .ReadAll (resp .Body )
118118	if  err  !=  nil  {
119- 		return  nil , err 
119+ 		return  nil , resp . StatusCode ,  err 
120120	}
121121
122122	supertokens .LogDebugMessage (fmt .Sprintf ("Received response with status %d and body %s" , resp .StatusCode , string (body )))
123123
124124	var  result  map [string ]interface {}
125125	err  =  json .Unmarshal (body , & result )
126126	if  err  !=  nil  {
127- 		return  nil , err 
127+ 		return  nil , resp . StatusCode ,  err 
128128	}
129129
130130	if  resp .StatusCode  >=  300  {
131- 		return  nil , fmt .Errorf ("POST request to %s resulted in %d status with body %s" , url , resp .StatusCode , string (body ))
131+ 		return  nil , resp . StatusCode ,  fmt .Errorf ("POST request to %s resulted in %d status with body %s" , url , resp .StatusCode , string (body ))
132132	}
133133
134- 	return  result , nil 
134+ 	return  result , resp . StatusCode ,  nil 
135135}
136136
137137// JWKS utils 
0 commit comments