How to create simple webhooks for asana - node.js

I'm new to asana API and need help in creating webhooks to track activities in asana. a simple example using NodeJS would be fine. thank you.

Check this out: https://github.com/Asana/node-asana
A JavaScript client (for both Node and browser) for the Asana API v1.0.
Install with npm:
npm install asana --save
Browser
Include the latest release directly from GitHub.
<script src="https://github.com/Asana/node-asana/releases/download/<LATEST_RELEASE>/asana-min.js"></script>
OR
Download the latest distribution in releases.
Make sure to serve it from your webserver.
Include it on the client from a SCRIPT tag.
Usage
To do anything, you'll need always an instance of an Asana.Client configured with your preferred authentication method and other options.
The most minimal example would be as follows:
const asana = require('asana');
const client = asana.Client.create().useAccessToken('my_access_token');
client.users.me().then(function(me) {
console.log(me);
});

Related

Stripe error: EventEmitter is not a constructor

Hello,
I'm working on project that use Stripe for payments, framework this project uses is SvelteKit and for convenience I also use TS.
I implemented Stripe payments, tested locally, everything worked fine, then I deployed project to Firebase cloud functions and then 1st error showed up. Endpoint for creating payment intents failed every time I called it (but only in FB cloud function, it never failed locally).
So I decided (not just because of this bug) to move function for generating payment intents to one of my __layout.svelte, where it can be called from front-end and executed on back-end without need to make HTTP request to endpoint that is exposed to whole internet.
Stripe config:
import Stripe from "stripe";
console.log('secret defined:', import.meta.env.VITE_STRIPE_SECRET_KEY);
const stripe = new Stripe(import.meta.env.VITE_STRIPE_SECRET_KEY, {
apiVersion: '2020-08-27',
});
console.log('after stripe conf');
export default stripe;
I moved that function to desired __layout.svelte and got error EventEmitter is not a constructor.
Then I found this question, and did what answer advised. Then I got different error:
http.Agent is not a constructor.
Well, this is quite difficult problem, it is related to Vite. Stripe API for back-end is written in CJS and Vite has problems with processing CJS code when using SSR. According to docs I should include stripe for optimization, but that didn't work. These Github issues better describe this problem: Svelte issue Vite issue.
I'm lucky enough that I use Firebase, so I fixed this by moving function for generating payment intents to Cloud Functions. So this is solution for me, and not for everyone, but I hope this will help someone.

How to sync react native app with express app?

I am using react native android app for recording calls.Once the call get recorded, it should be uploaded to serer(express js and mysql) with call details.Suppose the app is in offline the file should uploaded to server whenever the app comes to online.How should i acheive this.
NOTE: All the above mentioned process should be run in background.
I found some solutions like pouchdb. For react native (pouchdb-react-native) npm and for express js (express-pouchdb) using this npm can i achive the sync? and how?
It is possible - using PouchDb server and LevelUp - to sync PouchDb with different backend databases. See this answer for details and the Nolan Lawson article on LevelUp.

Firebase host:i can deploy but how to hide source code

i have deployed my website by using Firebase host but when i do Right Click > View page source: i can see source code and my firebase Project information
So How can i hide it ; Will i have to use Node.js ? or Cloud functions ?
i have tried node's http npm
const http = require ('http');
onRequest();
function onRequest (req , res){
http.createServer(onRequest).listen(3000);
console.log("Success");
}
but it does not help
i am really confused please help me
If you want to hide some stuff from your users you will need to hide it in the server side. So with Firebase, you can use the Firebase Cloud Function. They accept nodejs, python and typescript. If you want to store variable in your website, then use the database.
After that, make sure to set your database rules safely.

Clarifai API for Local Image

I'm trying to make a nodejs application that captures an image from the computer's webcam, and then uses Clarifai API to recognize what is in that picture. I haven't figured out how to do that for local images, however, as the method I'm using, the one presented in the 'Getting Started' section of the API, only works with urls, and not local file paths.
ofcourse it works with localfile also but with client side java script SDK. (not with node js). for client side clarifai SDk add
<script type="text/javascript" src="https://sdk.clarifai.com/js/clarifai-latest.js"></script>
in html header and inti sdk using
const app = new Clarifai.App({
apiKey: 'YOUR_API_KEY'
});
by adding sdk you got Clarifai as global varible for example go to offical clarifai demo https://www.clarifai.com/demo and open console and type Clarifai and got magic,
if done this magic then now it's time to go https://clarifai.com/developer/guide/

Node.js install cloudant module

Hi I am making a Cordova app for iOS and Android. I am trying to use the cloudant module https://github.com/cloudant/nodejs-cloudant to access my cloudant couchDB, but for the life of me, I cannot figure out the issue I am having while installing it. Using linux, I executed npm install --save cloudant at the root of my Cordova project folder. When using var Cloudant = cordova.require('cloudant'); in my code, I get the error Uncaught module cloudant not found from within my cordova.js file as it tries to load the module. Also when I run $ node -e 'require("cloudant"); console.log("Cloudant works");' in my shell, I receive a terminal output stating "Cloudant works". I cannot seem to figure out what the issue is, and have tried many different things. Any help is extremely appreciated, as I am at my witts end at this point. Thanks.
As #Parth says, 'nodejs-cloudant' is a Node.js/npm module. To access Cloudant from within your Cordova application you will need client side code to interact with Cloudant's HTTP API.
You could use jQuery's Ajax functions to make HTTP requests to Cloudant or you can use PouchDB as a client-side library e.g:
<script src="pouchdb-3.4.0.min.js"></script>
<script>
var db = new PouchDB("https://myusername:mypassword#myaccount.cloudant.com/mydb";
</script>
Both solutions require you to enable CORS on your Cloudant account.
'nodejs-cloudant' is an npm module and not a cordova module. you just need to write
var Cloudant = require('cloudant'); That should solve the problem.
Try with this:
var Cloudant = require('cloudant');
Instead of importing cloudant directly, try using cradle or nano for accessing cloudant
'DB.const nano = require('nano')('//cloudant api link//');'
This works
https://www.npmjs.com/package/nano#dbinsertdoc-params-callback
https://www.npmjs.com/package/cradle

Resources