Skip to content

Tag: javascript

How to use optional chaining in Node.js 12

Optional chaining (obj?.param1?.param2) seems to be a great feature and I really wanted to see it implemented and finally get rid of nested ifs, arbitrary functions and what not for such a simple operation. But there’s a problem, it doesn’t work. I updated to Node 12 and I still get an error: or W…

remove all next divs after a child

I have something like this : using this: This will hide only the content i marked on the code, means only childs of the same parent. I need to hide every single thing after productPage. Answer You should also go to parent and target the next divs.

I can’t reference an image in Next.js

I have a React component that’s being used in Next.js page: /pages/index.js In Main.js I have the following code I get the following error Module parse failed: Unexpected character ‘�’ (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to p…

Execute function after every post request

Using Axios is there a way to “hook” a function to every post request? I have a ‘notification’ module in Vue.js store, which stores API responses, so I need to call an updateResponse method in every post request .then Answer Just use Axios interceptors

How to Inject Axios in Puppeteer

I want to inject axios in puppeteer in order to open a browser session, but sending requests and receiving responses through axios: So the question is, is it possible? Here’s my attempt, but it is not working since axios doesn’t intercepts the website responses I’m moving my first steps in a…

Using baseUrl in jsconfig.json is not working with Next.js

jsconfigerror is an example repository showing the jsconfig is not working. I have the following set inside my jsconig.json file: However, when I do an import, it fails: Folder Structure pages/index.js How can I get baseUrl to work with Next.js? Answer Since Next.js 9.4, Next.js automatically supports the tsc…