NativeScript / nativescript-background-http

Background Upload plugin for the NativeScript framework
Apache License 2.0
102 stars 50 forks source link

serverResponse is null #66

Closed giscafer closed 7 years ago

giscafer commented 7 years ago

java

@RequestMapping(value = "/appUploadImage",method= RequestMethod.POST)
    public List<UploadFileVo> appUploadImage(HttpServletRequest request,HttpServletResponse response) throws IOException {
        InputStream inputStream = request.getInputStream();
        UploadFileVo uploadFileVo = uploadService.saveFile(inputStream);
        return Lang.list(uploadFileVo);
    }

the upload is success,but can't get the return value

I want to get the return value Lang.list(uploadFileVo)

js

task.on("complete", function(e,response){
        console.log('response')
        console.dump(response)
    });

response is null,

giscafer commented 7 years ago

see https://github.com/NativeScript/NativeScript/issues/4154

acharyaks90 commented 5 years ago

I want to Check the response in error block but it gives task.on("error", event => { console.dir(event); console.log(JSON.stringify(event)) console.log(event.responseCode); console.log(event.response.data) });


eventName: "error" JS: object: { JS: "_observers": { JS: "complete": [ JS: {} JS: ], JS: "error": [ JS: {} JS: ], JS: "responded": [ JS: {} JS: ] JS: }, JS: "_session": { JS: "_id": "file-upload" JS: }, JS: "_id": "file-upload{1}", JS: "_description": "Log File", JS: "_upload": 4309, JS: "_totalUpload": 4309, JS: "_status": "error" JS: }

JS: error: "null" JS: responseCode: "400" JS: response: net.gotev.uploadservice.ServerResponse@73e7f34

I want to read response , Please help me in reading the response.

acharyaks90 commented 5 years ago

Hi i got answer from stack overflow
const responseObj = event.response && JSON.parse(event.response.getBodyAsString()); https://stackoverflow.com/questions/54707871/inappropriate-server-response-in-upload-failure-error-block-net-gotev-uploadserv/54710389#54710389

Srikanthjava972 commented 2 years ago

the above solution is not working @acharyaks90 @giscafer @EmilStoychev, can anyone help me. How should I read the error response from server.