MCPcopy Create free account
hub / github.com/keepfool/vue-tutorials / body

Function body

06.Router/basic/js/vue-resource.js:791–821  ·  view source on GitHub ↗
(request, next)

Source from the content-addressed store, hash-verified

789 }
790
791 function body (request, next) {
792
793 if (request.emulateJSON && isPlainObject(request.body)) {
794 request.body = Url.params(request.body);
795 request.headers['Content-Type'] = 'application/x-www-form-urlencoded';
796 }
797
798 if (isFormData(request.body)) {
799 delete request.headers['Content-Type'];
800 }
801
802 if (isPlainObject(request.body)) {
803 request.body = JSON.stringify(request.body);
804 }
805
806 next(function (response) {
807
808 var contentType = response.headers['Content-Type'];
809
810 if (isString(contentType) && contentType.indexOf('application/json') === 0) {
811
812 try {
813 response.data = response.json();
814 } catch (e) {
815 response.data = null;
816 }
817 } else {
818 response.data = response.text();
819 }
820 });
821 }
822
823 function jsonpClient (request) {
824 return new Promise$1(function (resolve) {

Callers

nothing calls this directly

Calls 4

isPlainObjectFunction · 0.70
isFormDataFunction · 0.70
nextFunction · 0.70
isStringFunction · 0.70

Tested by

no test coverage detected