You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: jsServer.go
    path of file: ./repos/dendrite/build/dendritejs-pinecone
    
    the code of the file until where you have to start completion: // Copyright 2020 The Matrix.org Foundation C.I.C.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build wasm
// +build wasm

package
    
func (h *JSServer) OnRequestFromJS(this js.Value, args []js.Value) interface{} {
	// we HAVE to spawn a new goroutine and return immediately or else Go will deadlock
	// if this request blocks at all e.g for /sync calls
	httpStr := args[0].String()
	promise := js.Global().Get("Promise").New(js.FuncOf(func(pthis js.Value, pargs []js.Value) interface{} {
		// The initial callback code for new Promise() is also called on the critical path, which is why
		// we need to put this in an immediately invoked goroutine.
		go func() {
			resolve := pargs[0]
			resStr, err := h.handle(httpStr)
			errStr := ""
			if err != nil {
				errStr = err.Error()
			}
			resolve.Invoke(map[string]interface{}{
				"result": resStr,
				"error":  errStr,
			})
		}()
		return nil
	}))
	return promise
}