await is only valid in async function

The error is not refering to myfunction but to start.  Run code snippetExpand snippet I use the opportunity of this question to advise you about an known anti pattern using await which is : return await. WRONG  Run code snippetExpand snippet CORRECT  Run code snippetExpand snippet Also, know that there is a special case where return await is correct and important : (using … Read more

How to iterate over a JavaScript object?

For most objects, use for .. in : With ES6, if you need both keys and values simultaneously, do To avoid logging inherited properties, check with hasOwnProperty : You don’t need to check hasOwnProperty when iterating on keys if you’re using a simple object (for example one you made yourself with {}). This MDN documentation explains more generally how to deal with objects … Read more

Unexpected token u in JSON at position 0 (but only sometimes)

That unexpected “u” is the first letter of the string “undefined”. It happens because your two asynchronous operations (i.e. loading the JSON and loading the window) are racing to completion, and if the JSON isn’t loaded fast enough, the window.onload method will attempt to parse the JSON string that isn’t loaded yet. A solution is to move … Read more

“document.getElementByClass is not a function”

You probably meant document.getElementsByClassName() (and then grabbing the first item off the resulting node list): You may still get the error document.getElementsByClassName is not a function in older browsers, though, in which case you can provide a fallback implementation if you need to support those older browsers.ShareImprove this answerFollow

Download File Using JavaScript/jQuery

Use an invisible <iframe>: To force the browser to download a file it would otherwise be capable of rendering (such as HTML or text files), you need the server to set the file’s MIME Type to a nonsensical value, such as application/x-please-download-me or alternatively application/octet-stream, which is used for arbitrary binary data. If you only want to open it in a … Read more

TypeScript React.FC confusion

Function ComponentsThese can be written as normal functions that take a props argument and return a JSX element. What about React.FC/React.FunctionComponent? You can also write components with React.FunctionComponent (or the shorthand React.FC): Some differences from the “normal function” version: It provides typechecking and autocomplete for static properties like displayName, propTypes, and defaultProps – However, there are currently known issues using defaultProps with React.FunctionComponent. See this issue for details … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)