I'm trying to use angular-file-uploader and upload a file. in afuConfig, I want to set method to POST but in terminal I have errors.
uploadAPI: {
url:"https://example-file-upload-api",
method:"POST",
headers: {
"Content-Type" : "text/plain;charset=UTF-8",
},
}
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
it gives me this:
The types of 'uploadAPI.responseType' are incompatible between these types.
Type 'string' is not assignable to type '"blob" | "json" | "arraybuffer" | "text" | undefined'.
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
I have the same problem for using responseType too.
CodePudding user response:
The default responseType
is json
. Try to assign the responseType: text
explicitly
uploadAPI: {
url: "https://example-file-upload-api",
method:"POST",
headers: {
"Content-Type" : "text/plain;charset=UTF-8",
},
responseType: 'text'
}
CodePudding user response:
try below code for headers:
httpOptions: {
headers:{
accept: 'application/pdf'
}
responseType: 'blob',
}