Ошибка при использовании метода Post AngularJs - PullRequest
0 голосов
/ 06 июля 2018

кто-то может это исправить, когда я использую почтальон, мой отдых хорош, но не со стороны клиента

   var req = {
        method: 'POST',
        url: 'http://localhost:8098/getfiles',
        headers: {
          'Content-Type': 'multipart/form-data',
        },
        data: { 'selectedFiles': 'D:\\quadtech\\Intellegent\\AppSpringBoot\\input\\bismillah.txt' }
    }   
    return $http(req).then(function(response){console.log(response); return response;}, function(){});

ошибка в моей консоли

POST http://localhost:8098/getfiles 500 ()

это запрос от почтальона enter image description here

1 Ответ

0 голосов
/ 06 июля 2018

Отправка с использованием formData вместо данных:

    var req = {
            method: 'POST',
            url: 'http://localhost:8098/getfiles',
            headers: {
              'Content-Type': 'multipart/form-data',
            },
            formData: {
              'selectedFiles': fs.createReadStream('D:\\quadtech\\Intellegent\\AppSpringBoot\\input\\bismillah.txt') }
            }   
        return $http(req).then(function(response){console.log(response); return response;}, function(){});

см. Документы: https://github.com/request/request#forms

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...