Skip to content

Instantly share code, notes, and snippets.

@xErik
Last active September 20, 2019 09:01
Show Gist options
  • Save xErik/ffaccc54f498b36f99900d100fb49433 to your computer and use it in GitHub Desktop.
Save xErik/ffaccc54f498b36f99900d100fb49433 to your computer and use it in GitHub Desktop.
// ./src/app/functionstest/functionstest.tl
import { Component, OnInit } from '@angular/core';
import { AngularFireFunctions } from '@angular/fire/functions';
@Component({
selector: 'app-functiontest',
template:'<p style="border:1px red solid;margin-top:50px">{{ out }}x</p>'
})
export class FunctiontestComponent implements OnInit {
constructor(private func: AngularFireFunctions) {}
out:string ='';
ngOnInit() {
this.func.httpsCallable('helloWorld')({ text: 'Some Argument' })
.toPromise()
.then(resp => {
console.log( resp );
this.out = JSON.stringify(resp);
})
.catch(err => {
console.error({ err });
});
}
}
// ./functions/src/index.ts
import * as functions from 'firebase-functions';
export const helloWorld = functions.https.onCall((data, context) => {
return { message: "Hello from Firebase!" };
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment