I am implementing a Music Download website in ReactJs using Yii2 API.

I have written a download function in Yii2 that looks like

public function actionDownloadmusic(){
    $post = \yii::$app->request->post();
    return \Yii::$app->response->sendFile($post['link']);

In my reactJs, I make a request to this function hoping it will open-up the small download window to save file but I dont get any response from that.

    const {user} = this.props;
    const requestOptions = {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({

I have done lots of modifications to this and none of them work. Please any ideas or help is highly needed.

Note: the link sent to the API is already constructed for download but I don not want to use

0 Answers