Los Angeles, CA

Category: Javascript

How do I convert an existing callback API to promises?

function isIt(){ let someOp = true if(someOp) return ‘its true’ else return ‘no bueno’ } //becomes function isIt() { return new Promise(function(resolve, reject) { let someOp = true if(someOp) resolve(‘its true’) else reject(‘no bueno’) }); }

react-s3-uploader 403 error

react-s3-uploader 403 error

While looking at react-s3-uploader’s npm documentation it seemed really cool and the fastest way to get the job done so on the react side all we had to add was <ReactS3Uploader className={‘uploader’} signingUrl=”/s3/sign” signingUrlMethod=”GET” accept=”.doc,.docx,.pdf” s3path=”/uploads/” onProgress={this.onProgress} onError={this.onError} onFinish={this.onFinish} uploadRequestHeaders={{ ‘x-amz-acl’: ‘public-read’ }} ref={fileInput => (this.fileInput = fileInput)} contentDisposition=”auto” /> and on the node side…
Read more

JSON array of US states

JSON array of US states

Every form we build we are looking for a JSON or a JS array of US states that we can export from a constant file export const states = [ { text: ‘Alabama’, value: ‘AL’, }, { text: ‘Alaska’, value: ‘AK’, }, { text: ‘American Samoa’, value: ‘AS’, }, { text: ‘Arizona’, value: ‘AZ’, },…
Read more

JSON array of countries

JSON array of countries

Almost every form we build we are looking for a JS array of all countries. Here it is export const countries = [ { text: ‘United States’, value: ‘US’ }, { text: ‘Afghanistan’, value: ‘AF’ }, { text: ‘Åland Islands’, value: ‘AX’ }, { text: ‘Albania’, value: ‘AL’ }, { text: ‘Algeria’, value: ‘DZ’ },…
Read more

How to setup ESLint to use AirBnB’s React rules with a React application

How to setup ESLint to use AirBnB’s React rules with a React application

Setting up ESLint can seem daunting but luckily we can help  We hope you know why you are doing it but if not in short ESLint and Prettier can help your team maintain code quality and same formatting throughout the project. If your company has more than 1 frontend developer you will realize different developers…
Read more

Send text using Javascript

/* for demo and quick start place this code in your app.js or server.js please run ‘npm install puretext –save’ in terminal */ const puretext = require(‘puretext’); require(‘request’); let text = { // To Number is the number you will be sending the text to. toNumber: ‘+X-XXX-XXX-XXXX’, // From number is the number you will…
Read more

What constitutes a Javascript Design Pattern?

It solves a problem but beyond that, it’s a proven concept just because something solves a problem does not make it a design pattern it has to be a proven concept that works in a lot of different areas in a lot of different applications and the solution of the problem cannot be obvious. It…
Read more

Three ways to create a JavaScript object

There are three ways to create a new object in JS var obj = {}; var objFoo = Object.create(Object.prototype); var lastObj = new Obj(); Which one do you use?