node-XMLHttpRequest icon indicating copy to clipboard operation
node-XMLHttpRequest copied to clipboard

"xmLHttpRequest is not defined"

Open ialameh opened this issue 5 years ago • 0 comments

I tried to generate a node from the following code and I am getting an error

"xmLHttpRequest is not defined"

whenever the code is run (as a google cloud function)

this is my code

import 'package:firebase_functions_interop/firebase_functions_interop.dart'; import 'package:rest_client/rest_client.dart' as rc;

void main() {
  functions['sendInvites'] = functions
      .region('us-central1')
      .firestore
      .document('/invitations/{id}')
      .onCreate(createHook);
}

Future<void> createHook(DocumentSnapshot snapshot, EventContext context) async {
  final name = snapshot.data.getString('name');
  final data = DocumentData.fromMap({'name': name});
  await snapshot.firestore.collection('/bar').add(data);
  //    //    print('posting $jsonToPost');
   var client = rc.Client();
   var request = rc.Request(
             url: 'http://myurl:1337/parse/classes/profile',
       headers: {
         "X-Parse-Application-Id": "mysuperawesomekey",
         "X-Parse-Master-Key": "theyshouldchangemastertosomethngelse"
       },
       body: '{"name" : "$name"}',
       method: rc.RequestMethod.post);
   try {
     await client.execute(request: request);
   } catch (e) {
     print(e);
   }

}

do you have any idea how i can get this to work

ialameh avatar Sep 04 '20 09:09 ialameh