Git Product home page Git Product logo

notes's Introduction

notes's People

Contributors

taosin avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

notes's Issues

使用axios发送POST请求时后端获取不到参数的问题

使用axios发送POST请求时后端获取不到参数的问题

在使用 vue2 + axios + node.js + express 开发管理后台时,遇到了axios发送POST请求时后端获取不到参数的问题 ,查阅资料许久,还是未找到解决办法,无奈之下,喝一口凉水,歇息一番,继续寻求良方。

终于,皇天不负有心人,在这里,还是找到了解决的办法。

axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

由此看出,axiosPOST 提交数据时也是使用的这种方式,在 javaphp 可以获取到对应的 request 原始流数据获取到对应的值并将其序列化.

但是这样的方式在 express 服务后端并不能获取到数据,因此 express 中使用的是 body-parser 去格式化前台传来的数据,具体实现看代码:

//server

'use strict'
var express = require('express')
var powerexpress = require('power-express')(express)
var authority = require('./filter/authority')
var app = powerexpress()

// 使用 body-parse 格式化数据
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({
    extended: true
}))
app.use(bodyParser.json())



var Server = require('./server')
var cookieParser = require('cookie-parser')
app.use(cookieParser())
require('./controllers/routes')(app)
var appServer = new Server(app)
appServer.start()

关于js页面中oss在https下web直传的问题

关于js页面中oss在https下web直传的问题

在页面中进行web端直传,开发环境下测试没有问题,但部署到服务器上时出现了问题,服务器上的站点是基于https协议进行访问的,在此情况下,web端直传出现了异常,原因是在HTTPS的网页中,不允许发起HTTP的请求,可以使用https的endpoint,示例如下:

var client = new OSS.Wrapper({ 
  region: 'oss-cn-shanghai', 
  secure: true,     //为true时,即允许发起http请求
  accessKeyId: '', 
  accessKeySecret: '' 
}); 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.