0

I am using angularjs to pass the data to back end(python flask)

var currenttopic = "All";
    $http.post("/CA/"currenttopic,date).success(function(response){
                console.log(response);
            });

and in backend the python flask code is something like

@app.route('/CA/<topic>', methods=['POST'])
@login_required
def competitivepertopic(topic):
    if request.method == 'POST':
        print(topic)
        data = request.get_json()
        pass
    return json.dumps({'data': topic})

now how can i pass currenttopic variable to backend?

1
  • that is a different question Commented Oct 30, 2017 at 7:37

1 Answer 1

2

Try it like this:

$http.post("/CA/" + currenttopic, date).success(function(response) {

or with ES6:

$http.post(`/CA/${currenttopic}`, date).success(function(response) {
Sign up to request clarification or add additional context in comments.

2 Comments

is that a tilde symbol?
the first line worked for me. thanks for the help

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.