Skip to content
Advertisement

Undefined Json response from django backend to chrome extension alert

Hi i am trying to return a json file to the chrome extention to show it to the user, the query go to server without a problem, fetched url is also working and does return the json file when i try it directly, but the chrome extention shows "undefined" message in the alert instead of the json file.

the returned json file have this type : JsonResponse(data)

data is a dict[str, Union[str, list]],

another question, is how can I show the json file in the popup html page?

to my chrome extension code:

Manifest.json:

JavaScript

popup.js:

JavaScript

Background.js:

JavaScript

here is the python code:

JavaScript

and the parse function:

JavaScript

Advertisement

Answer

All problem is in Python code.

In JavaScript you want to display summary

JavaScript

and in Python in parsefile() you create

JavaScript

but later you send Product instead of data

JavaScript

so your

JavaScript

means

JavaScript

instead of

JavaScript

In parsefile() you should do

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement