Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading 'catch') #369

Open
syamsoul opened this issue Apr 25, 2022 · 6 comments
Open

TypeError: Cannot read properties of undefined (reading 'catch') #369

syamsoul opened this issue Apr 25, 2022 · 6 comments

Comments

@syamsoul
Copy link

syamsoul commented Apr 25, 2022

vue file

<template>
    <div id="page_product_file_view" class="general-pages-1">
        <template v-for="i in numPages">
            <pdf
    			:key="i"
    			:src="pdf_src"
    			:page="i"
    			style="display: inline-block; width: 100%"
    		></pdf>
            <hr>
        </template>
    </div>
</template>
<script>
import pdf from 'vue-pdf'


export default {
    components:{
        pdf
    },
    data: () => ({
        pdf_src: null,
        numPages: undefined,
    }),
    mounted() {
        this.pdf_src = pdf.createLoadingTask(`${MAIN_URL}/file/view/${this.$route.params.hfilname}`);
        this.pdf_src.promise.then(pdf => {
			this.numPages = pdf.numPages;
		});
    },
    methods: {

    },
}
</script>

.
.

pdf file successfully displayed
image

.
.

but it produces lot of errors in console

TypeError: Cannot read properties of undefined (reading 'catch')
    at PDFJSWrapper.renderPage (app.js?id=b89a6ec318209e4c9370:1:670908)
    at o.resize (app.js?id=b89a6ec318209e4c9370:1:661909)
    at Ht (app.js?id=b89a6ec318209e4c9370:1:402599)
    at o.n (app.js?id=b89a6ec318209e4c9370:1:404333)
    at Ht (app.js?id=b89a6ec318209e4c9370:1:402599)
    at o.t.$emit (app.js?id=b89a6ec318209e4c9370:1:424764)
    at o.handler (app.js?id=b89a6ec318209e4c9370:1:659744)
    at pn.INkZ.pn.run (app.js?id=b89a6ec318209e4c9370:1:418869)
    at fn (app.js?id=b89a6ec318209e4c9370:1:416881)
    at Array.<anonymous> (app.js?id=b89a6ec318209e4c9370:1:403637)
@syamsoul syamsoul changed the title [Vue warn]: Error in v-on handler: "TypeError: Cannot read properties of undefined (reading 'catch') found in <ResizeSensor> TypeError: Cannot read properties of undefined (reading 'catch') Apr 25, 2022
@Flamenco
Copy link

cancel() is not returning a promise.

this.renderPage = function(rotate) {
			if ( pdfRender !== null ) {

				if ( canceling )
					return;
				canceling = true;
				pdfRender.cancel().catch(function(err) {
					emitEvent('error', err);
				});
				return;
			}

devheedoo added a commit to devheedoo/vue-pdf that referenced this issue May 18, 2022
- pdfRender.cancel is not an async function
  (unavailable to use catch chaining)
- related to FranckFreiburger#369
devheedoo added a commit to devheedoo/vue-pdf that referenced this issue May 18, 2022
- pdfRender.cancel is not an async function
  (unavailable to use catch chaining)
- related to FranckFreiburger#369
devheedoo added a commit to devheedoo/vue-pdf that referenced this issue May 18, 2022
- pdfRender.cancel is not an async function
  (unavailable to use catch chaining)
- related to FranckFreiburger#369
devheedoo added a commit to devheedoo/vue-pdf that referenced this issue May 18, 2022
- pdfRender.cancel is not an async function
  (unavailable to use catch chaining)
- related to FranckFreiburger#369
devheedoo added a commit to devheedoo/vue-pdf that referenced this issue May 18, 2022
- pdfRender.cancel is not an async function
  (unavailable to use catch chaining)
- related to FranckFreiburger#369
devheedoo added a commit to devheedoo/vue-pdf that referenced this issue May 18, 2022
- pdfRender.cancel is not an async function
  (unavailable to use catch chaining)
- related to FranckFreiburger#369
@devheedoo
Copy link

Sorry for comments from my rebase commit... 🙏

@luisrossi
Copy link

@SHIVAM-lab
Copy link

use optional chaining there .
Like
await RecruiterDbModel.findOneAndUpdate(
{
_id: _id,
},
{
$set: recruiterUpdateObject,
},
)
.then(recruiter => {
recruiterObject = recruiter;
})
?.catch(err => {
Logger.error(err);
});

@Shivamlab
Copy link

use optional chaining there . Like await RecruiterDbModel.findOneAndUpdate( { _id: _id, }, { $set: recruiterUpdateObject, }, ) .then(recruiter => { recruiterObject = recruiter; }) ?.catch(err => { Logger.error(err); });

worked for me , thanks for the answer

@teckel12
Copy link

teckel12 commented Apr 7, 2023

As this project seems to be abandoned, I created a fork which corrects this bug. The package can be found here:

https://www.npmjs.com/package/@teckel/vue-pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants