How i can dynamic my flash message in angular. message must be coming through API response - angularjs

My flash message code is below
<div class="flash-message" ng-if="flash">
<div class="{{'alert alert-' + flash.type}}" ng-bind="flash.message">
</div>
Right now i am using
FlashService.Success('You have blocked this User');
I want to make my above message dynamic, i have passed static right now.
My node api is return this message right now
{
"data": {
"status": "1",
"msg": "You have blocked the user"
}
}

Pass the result in function callback.
{
"data": {
"status": "1",
"msg": "You have blocked the user"
}
}
Put the below code to make flash Message dynamic.
FlashService.Success(result.data.msg);

Related

Instagram: invalid message data error while trying to send pushback buttons

Using https://graph.facebook.com/v13.0/me/messages?access_token=pagetoken post url trying to send pushback buttons. But its gives error as:
"message": "(#100) Invalid message data",
"type": "OAuthException",
"code": 100,
"error_subcode": 2534015
**Request-body:**
{
"recipient":{
"id":"PSID"
},
"message":{
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text":"Try the postback button!",
"buttons":[
{
"type":"postback",
"title":"Postback Button",
"payload":"DEVELOPER_DEFINED_PAYLOAD"
}
]
}
}
}
}
This one is not supported by instagram anymore, try generic type with post back button https://developers.facebook.com/docs/messenger-platform/instagram/features/generic-template

Firebase Cloud Firestore - Fail to write via REST API

This is not an authentication error, write is enabled on the database rules.
My cloud Firestore database looks like the picture below.
There is a COLLECTION called colA, inside it there is a DOCUMENT called docA, and inside it there are some fields (strings) stored.
On Postman, if I do GET https://firestore.googleapis.com/v1/projects/eletronica-ab6b1/databases/(default)/documents/colA/docA, I do receive the following answer, and it is correct:
{
"name": "projects/eletronica-ab6b1/databases/(default)/documents/colA/docA",
"fields": {
"fieldB": {
"stringValue": "ABCD"
},
"fieldA": {
"stringValue": "888"
}
},
"createTime": "2020-01-31T16:48:26.859181Z",
"updateTime": "2020-02-05T19:21:49.654340Z"
}
Now, when I try to write a new field (fieldC) via POST https://firestore.googleapis.com/v1/projects/eletronica-ab6b1/databases/(default)/documents/colA/docA, with JSON content:
{
"name": "projects/eletronica-ab6b1/databases/(default)/documents/colA/docA",
"fields": {
"fieldC": {
"stringValue": "1000"
}
}
}
After SEND, I receive this:
{
"error": {
"code": 400,
"message": "Document parent name \"projects/eletronica-ab6b1/databases/(default)/documents/colA\" lacks \"/\" at index 60.",
"status": "INVALID_ARGUMENT"
}
}
What I'm doing wrong? I really would like to write strings there via REST API.
Regards.
Updating a document is done with a PATCH request, according to the [reference documentation).
A POST request is used to create a new document in a collection, which probably explains the error you get: you're pointing to a document, but POST expects a collection path.

Alexa skill is giving 'There was a problem with the requested skill's response', can we change this message to custom message?

I am new to Alexa skill, and I am developing an Alexa skill, in my case there are scenario when I don't want to wait for http response to back and if my lambda timeouts due to delay in response from Http can I give a custom message in place of 'There was a problem with the requested skill's response'. My code is :
'ProtectArmIntent': function() {
if(checkAccessToken(this.event.session.user.accessToken)){
var data = {
mode: HUB_MODE.ARM,
regId: "null"
}
callAPI("post", API_COMMANDS.HUB_MODE, data, this.event.session.user.accessToken)
.then((body) => {
if(body.response.status === "SUCCESS"){
this.emit(':tell', messages.ARM.SUCCESSFUL);
} else {
this.emit(':tell', messages.ARM.FAILED);
}
})
.catch((err) => {
this.emit('SessionEndedRequest');
//errorHandler.call(this, err, messages.ARM.FAILED);
});
} else {
this.emit('LinkAccount');
}
},
and alexa simulator request:
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.67e1612e-f8a4-43f5-ab28-175ba7d7941f",
"timestamp": "2019-11-13T21:13:11Z",
"locale": "en-GB",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "An exception occurred while dispatching the request to the skill."
}
}
I know the issue is because lambda timeout as delay in the HTTP response, so can I give some customize message like Your command is accepted and it will be executed in some time.
Please please help, Thanks in advance
Making your own timer function might help. Set your timer lower than the lambda timeout and send your response at the end of the timer which will of course not lead to a lambda timeout error.This answer might help.

Delete label request returning 400 even though label exists

I am having issues with the label delete Gmail API.
No matter what label I submit, I get the error response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Invalid delete request"
}
],
"code": 400,
"message": "Invalid delete request"
}
}
To reproduce, I first make the request:
POST https://www.googleapis.com/gmail/v1/users/me/labels
{"labelListVisibility":"labelShow","messageListVisibility":"show","name":"C2"}
Which succeeds and then immediately after I send:
DELETE https://www.googleapis.com/gmail/v1/users/me/labels/C2
Which produces the aforementioned error. I can see the label in my gmail inbox so I know it is successfully created and present. Any advice on what I am doing wrong?
You cannot delete a label by name, but must do so by its ID
See here. The Id of the label is contained in the response of the
POST https://www.googleapis.com/gmail/v1/users/me/labels
request:
{
"id": "Label_3",
"name": "C1",
"messageListVisibility": "show",
"labelListVisibility": "labelShow"
}
You can also list all you labels to retrieve their IDs.
The delete request should look something like:
DELETE https://www.googleapis.com/gmail/v1/users/me/labels/Label_3
whereby Label_3 should be replaced by your label ID.

Receiving "Invalid 'changeType'" when subscribing to user created event

I am trying to create a Webhook (aka Subscription) for users who are created, updated, or deleted in Office 365.
With the "changeType": "updated" it works fine but with "changeType": "created" it returns an error:
This is the request:
{
"changeType": "created,updated,deleted",
"notificationUrl": "https://ourLink",
"resource": "users",
"expirationDateTime": "2017-12-16T14:49:57Z",
"clientState": "pe1g9gqiVsE6KnHTUuK9Tts3o660KOAw9YnavVfKhr22I7FlqC0tfMhpayxrqFP4orFPOjK0rppYtDicvxZosbvOEEgfy3YYoM3FGDwLQiW4MAdSCTdQkffuChjmB"
}
Error:
{
"header": 400,
"body": {
"error": {
"code": "InvalidRequest",
"message": "Invalid 'changeType' attribute: 'created'.",
"innerError": {
"request-id": "74454900-d3df-4962-b58e-cfd7ec7454bc",
"date": "2017-12-13T16:49:59"
}
}
}
}
Creating a subscription to a user resource is only available in the Beta API
but according to the documentation, it should work.
Based on the error message and that the User Webhook sample application only handles updated and deleted, this should be the expected behavior.
I'm also unable to find where in the documentation it states that a user resource accepts subscriptions for created. If you could provide a link I will make sure the documentation gets updated.

Resources